繁体   English   中英

DeploymentException: WELD-001408: 不满意的类型依赖<Class>在注入点使用限定符 @Default [BackedAnnotatedField]

[英]DeploymentException: WELD-001408: Unsatisfied dependencies for type <Class> with qualifiers @Default at injection point [BackedAnnotatedField]

在无法找到答案且包含 beans.xml 的场景中注入 bean 时出现以下异常:

Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type CustomerAgreementDaoImpl with qualifiers @Default
  at injection point [BackedAnnotatedField] @Inject public com.evry.integrator.snow.fetch.CustomerAgreementFetcher.customerAgreementDaoImpl
  at com.evry.integrator.snow.fetch.CustomerAgreementFetcher.customerAgreementDaoImpl(CustomerAgreementFetcher.java:0)

        at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:378)
        at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:290)

以下是代码结构:

/WEB-INF 中的 Beans.xml

<beans xmlns="http://java.sun.com/xml/ns/javaee" 
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
                           http://java.sun.com/xml/ns/javaee/beans_1_1.xsd"
       version="1.1" bean-discovery-mode="all"> 
</beans>

接口

public interface GenericDao<T, PK> {

public interface CustomerAgreementDao extends GenericDao<CustomerAgreement, Long>{

实现通用 DAO 的抽象类

public abstract class GenericDaoImpl<T, PK> implements GenericDao<T, PK> {

@PersistenceContext(unitName = "IntegratorMasterdataDS")
protected EntityManager em;

主要实现

@Stateless
public class CustomerAgreementDaoImpl extends GenericDaoImpl<CustomerAgreement, Long> implements CustomerAgreementDao {

public CustomerAgreementDaoImpl() {
    System.out.println("CustomerAgreementDaoImpl");
}

服务类中使用的道

@Stateless
public class CustomerAgreementFetcher {

    @Inject
    public CustomerAgreementDaoImpl customerAgreementDaoImpl;

主调度程序加载以上所有内容

@Startup
@Singleton
@AccessTimeout(value = 5, unit = TimeUnit.MINUTES)
public class WPoller {
    @Inject
    CustomerAgreementFetcher customerAgreementFetcher;

您可以将字段的类型更新为 CustomerAgreementDao 接口吗?

@Stateless
public class CustomerAgreementFetcher {

    @Inject
    public CustomerAgreementDao customerAgreementDao;

相关主题: 是否可以使用 CDI 注入 EJB 实现而不是其接口?

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM