ParametroSistemaHelper

ParametroSistemaHelper

我以这种方式注释了类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]

最佳答案

可能用ParametroSystemaHelper注释
@javax.faces.bean.ApplicationScoped代替@javax.enterprise.inject.ApplicationScoped。 CDI容器会在应用程序中扫描CDI bean,但由于未明确定义范围,因此找不到您的bean。
beans.xml包含bean-discovery-mode="annotated"或被省略时,这适用于CDI 1.1,这也意味着annotated发现模式。

08-04 04:25