【问题标题】:WELD-001408 Unsatisfied dependencies for type [DataSource] with qualifiersWELD-001408 带有限定符的类型 [DataSource] 的依赖关系不满足
【发布时间】:2014-08-19 15:17:45
【问题描述】:

我有以下导致 APP-A 中出现错误消息的原因

@Inject @CtcDB
private DataSource ds;

我正在使用与 APP-B 相同的模式,它不会抱怨此错误。 当我在 Eclipse 中按住 ctrl 键的同时将鼠标悬停在 ds 上时,我得到以下 APP-B 的上下文菜单

Open @Inject Bean Resource.ds
Open Declaration
Open Declared Type

但在 APP-A 中我只得到了依赖错误

Open Declaration
Open Declared Type

// 两个应用程序的资源类基本相同,除了限定符是@CommitmentDB for APP-B

public class Resources {
  @Produces
  @Resource(mappedName="java:jboss/datasources/myjndids")
  @CtcDB
  private DataSource ds;

//还有我的注释

@Qualifier
@Retention(RUNTIME)
@Target({ METHOD, FIELD, PARAMETER, TYPE })
public @interface CtcDB{

}

我知道 CDI 处于活动状态(我在 WEB-INF 中有一个 beans.xml),因为我有一个包含一些可注入 bean 的 POM 依赖项。当用 ctr 键悬停这些注入时,我得到了预期的上下文菜单(在两个应用程序中)

【问题讨论】:

    标签: eclipse jakarta-ee jboss cdi


    【解决方案1】:

    好吧,我自己想通了。在 Resources 类中,我对 DataSource 的导入错误

    import javax.activation.DataSource; \\instead of
    import javax.sql.DataSource;
    
    I must have clicked on the wrong Eclipse Quickfix and imported the wrong package.
    

    【讨论】:

      猜你喜欢
      • 2015-02-09
      • 2017-08-28
      • 1970-01-01
      • 1970-01-01
      • 2015-05-08
      • 2014-12-20
      • 1970-01-01
      • 2015-06-10
      • 2018-12-19
      相关资源
      最近更新 更多