【发布时间】: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< MSFOTContext> -
您确定该提供商在您的 Arquillian 部署中吗?它是在您的常规 WAR 中,还是您添加此版本以支持测试?
标签: java jboss cdi jboss-arquillian