【问题标题】:Unsatisfied dependencies for type [***<T>] with qualifiers [@Default] at injection point [[field] @Inject在注入点 [[field] @Inject 带有限定符 [@Default] 的类型 [***<T>] 的依赖关系不满足
【发布时间】:2017-07-27 09:12:34
【问题描述】:

部署到 jboss arquilian 服务器时,我遇到了以下问题(部署本地 jboss 服务器时似乎没有)

org.jboss.weld.exceptions.DeploymentException: WELD-001408 在注入点 [[field] @Inject com.athlon.thrift.web.utils.MSFOTContextUtils 带有限定符 [@Default] 的类型 [CarPolicyServiceWithContext] 的依赖关系不满足。 carPolicyService]

注入

@ApplicationScoped
public class MSFOTContextUtils {

    @Inject
    Logger logger;

    @Inject
    CarPolicyServiceWithContext carPolicyService;

提供者

@ApplicationScoped
public class ServiceProvider {

    @Inject
    @Any
    private Instance<CarPolicyServiceWithContext> carPolicyServices;



    private static final String COUNTRY = "NL";
    private static final Logger LOGGER = LoggerFactory.getLogger(ServiceProvider.class);

     @Produces
    public CarPolicyServiceWithContext getCarPolicyService() {
        Instance<CarPolicyServiceWithContext> found = carPolicyServices.select(
                new CountryQualifier(COUNTRY));
        LOGGER.info("CarPolicyServiceWithContext loaded"+found.toString());
        return found.get();
    }

    public static class CountryQualifier
            extends AnnotationLiteral<Country>
            implements Country {
        private String value;

        public CountryQualifier(String value) {
            this.value = value;
        }

        public String value() {
            return value;
        }
    }
}

@Country("NL")
@ApplicationScoped
public class CarPolicyNetherlandsService implements CarPolicyServiceWithContext<MSFOTContext> {

我在提供程序中添加了一些日志记录,但我没有看到它打印在 arquillian jboss 日志中......

谢谢!

【问题讨论】:

  • 您是否尝试过创建一个war文件并进行部署?在我看来,这更像是 CDI 配置的“问题”,而不是 arquillian 问题。
  • CDI 的类型非常安全,您的界面中有一个泛型。我不确定它与您的用例有什么相关性,但这意味着您必须将其引用为 CarPolicyServiceWithContext&lt; MSFOTContext&gt;
  • 您确定该提供商在您的 Arquillian 部署中吗?它是在您的常规 WAR 中,还是您添加此版本以支持测试?

标签: java jboss cdi jboss-arquillian


【解决方案1】:

在@Deployment 存档中,由于某种原因,上面的ServiceProvider 类没有添加到存档中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-05-04
    • 1970-01-01
    • 1970-01-01
    • 2020-08-12
    • 2015-02-26
    • 1970-01-01
    • 1970-01-01
    • 2020-03-26
    相关资源
    最近更新 更多