我用这种方式注释了类ParametroSistemaHelper:
@Named
@ApplicationScoped
public class ParametroSistemaHelper {
@Inject
private BasicDAO dao;
在此之后我试图在另一个类中使用它:
public abstract class BasicCrudMBImpl {
@Inject
private ParametroSistemaHelper parametroSistemaHelper;
但是当我尝试启动服务器(tomcat)时出现错误:
org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type ParametroSistemaHelper with qualifiers @Default
at injection point [BackedAnnotatedField] @Inject private br.com.jwebbuild.mb.BasicCrudMBImpl.parametroSistemaHelper
at br.com.jwebbuild.mb.BasicCrudMBImpl.parametroSistemaHelper(BasicCrudMBImpl.java:0)
我注意到在服务器启动时出现以下消息:
Managed Bean [class br.com.cardoso.mb.DisciplinaMBImpl] with qualifiers [@Default @Named @Any]
答案 0 :(得分:1)
可能ParametroSystemaHelper
注释为@javax.faces.bean.ApplicationScoped
@javax.enterprise.inject.ApplicationScoped
代替beans.xml
。 CDI容器扫描CDI bean的应用程序,但无法找到您的bean,因为未明确定义范围。
这适用于bean-discovery-mode="annotated"
包含annotated
时的CDI 1.1,或者被忽略,这也意味着struct
发现模式。