简体   繁体   English

当我在实体类中使用 @Inject 之类的依赖注入时,它会引发错误

[英]When I use dependecy injection like @Inject in my entity class it throw an error

@Stateless
public class MyAccountsBean {

    @Inject SomeEntityClass someOtherBean;
    @Resource UserTransaction jtaTx;
    @PersistenceContext(unitName="AccountsPU") EntityManager em;
    @Resource QueueConnectionFactory accountsJMSfactory;
    @Resource Queue accountPaymentDestinationQueue;

    public List<Account> processAccounts(DepartmentId id) {
        // Use all of above instance variables with no additional setup.
        // They automatically partake in a (server coordinated) JTA transaction
    }
}

There are likely multiple issues, but one that sticks out is that all of the fields should be marked with the private modifier.可能存在多个问题,但突出的一个问题是所有字段都应使用private修饰符进行标记。

In addition, can you post the rest of your codebase and the error you are getting?此外,您能否发布其余的代码库以及您遇到的错误?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用dagger2进行依赖注入时,我可以注入超类吗? - Can I just inject super class when use dagger2 for dependency injection? 为什么依赖注射使用公共方法? - Why does dependecy injection use public methods? 如何使用guice注入在具有静态方法的类中注入类? - How to use guice injection to inject a Class in a class with static methods? 重构与 Dagger 扩展相同抽象 class 的 32 个类的依赖注入 - Refactor dependecy injection of 32 classes that extend the same abstract class with Dagger 当我提交表单时,Spring仅在启动时注入我的类,我的变量为null为什么? - Spring inject my class only on my startup when I submit my form my variable is null why? 在Spring中将另一个实体类添加到annotedClasses列表时,出现错误“自动连接的依赖关系注入失败;” - Getting error “Injection of autowired dependencies failed;” when adding another entity class to annotedClasses list in spring 依赖注入不起作用 - Dependecy Injection not working 使用 doThrow() 不会抛出像 doThrow(null, NullPointerException.class) 这样的异常 - use doThrow() to NOT throw an exception like doThrow(null, NullPointerException.class) 将一个 class 扩展到另一个时抛出错误 - throw an error when extend one class to another 如果我在课堂上使用“实现”,则Spring Injection无法正常工作 - Spring Injection not working if i use “implements” in class
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM