java - 部署异常 : WELD-001408: Unsatisfied dependencies for type <Class> with qualifiers @Default at injection point [BackedAnnotatedField]

标签 java wildfly cdi jboss-weld wildfly-16

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

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>

接口(interface)

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");
}

Service类中使用的Dao

@Stateless
public class CustomerAgreementFetcher {

    @Inject
    public CustomerAgreementDaoImpl customerAgreementDaoImpl;

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

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

最佳答案

能否将该字段的类型更新为 CustomerAgreementDao 接口(interface)?

@Stateless
public class CustomerAgreementFetcher {

    @Inject
    public CustomerAgreementDao customerAgreementDao;

相关主题:Is it possible to inject EJB implementation and not its interface using CDI?

关于java - 部署异常 : WELD-001408: Unsatisfied dependencies for type <Class> with qualifiers @Default at injection point [BackedAnnotatedField],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59134836/

相关文章:

java - 您可以通过编程方式在 Java 中注册 ActiveX dll 吗?

java - 如何停止 Wildfly11 加载 jar 依赖 Web 服务

java - WildFly 8 和 Log4j 2 的 log4j-web 模块

Java Weld CDI 替代工厂

java - 将 API 回调绑定(bind)到 RxJava Observable

java - 如何从 JSON 接收到的 BASE64 字符串在 ImageView 中设置图像

java - 在 Recyclerview 中使用 picasso 时出现 IllegalArgumentException : Context must not be null.

java - 如何将用户主体从 HttpServletRequest 传播到 EJBContext?

java - 使用 CDI 的性能影响

CDI/焊接 : Disable late initialization/call of @PostConstruct