gpt4 book ai didi

java - 如何纠正 "The injection target must not be declared static."警告

转载 作者:行者123 更新时间:2023-12-02 01:34:48 24 4
gpt4 key购买 nike

我收到警告

“IssuePermitProcessManager.ecmManagerLocal 注入(inject)目标不得声明为静态。”

在我的 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";

我不清楚注入(inject)目标是什么。我是否只需从 protected static EcmManagerLocal ecmManagerLocal = null; 声明中删除 static 即可?

最佳答案

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

    @EJB
protected static EcmManagerLocal ecmManagerLocal = null;

    @EJB
protected EcmManagerLocal ecmManagerLocal;

关于java - 如何纠正 "The injection target must not be declared static."警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55381529/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com