有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何纠正“注入目标不能声明为静态的”警告

我收到了警告

“IssuePermitProcessManager.ecmManagerLocal注入目标不能声明为静态。”

在我的WebSphere 9服务器控制台上。我认为导致问题的代码是:

@Stateless
@TransactionManagement(TransactionManagementType.BEAN)
public class IssuePermitProcessManager implements IssuePermitProcessManagerRemote, IssuePermitProcessManagerLocal {

    @Resource
    private UserTransaction userTransaction;

    @EJB
    protected static EcmManagerLocal ecmManagerLocal = null;
    protected final static String EcmManagerLocal_JNDI = "ejblocal:gov.mo.dnr.ecwis.sessions.ecm.EcmManagerLocal";

我不清楚注射目标是什么。我只是从protected static EcmManagerLocal ecmManagerLocal = null;声明中删除static


共 (1) 个答案

  1. # 1 楼答案

    是的,ecmManagerLocal是一个声明为静态的注入目标(用@EJB注释它以注入ejb)。替换代码行

        @EJB
        protected static EcmManagerLocal ecmManagerLocal = null;
    

        @EJB
        protected EcmManagerLocal ecmManagerLocal;