[英]Unsatisfied dependencies for type with qualifiers @default at injection point
I'm working on a project with javaee-7.我正在使用 javaee-7 开发一个项目。 I have developed a new functionality in an external library and now I want to use the logic developed in the library in a micro-service.我在外部库中开发了一个新功能,现在我想在微服务中使用库中开发的逻辑。
Code from library库中的代码
public class Address {
public void addFormattedAddress(String country) {
if (country.equals("BR")) {
object.setFormattedAddress(new AddressFormatterForBR().createAddress(country));
} else if (country.equals("CN")) {
object.setFormattedAddress(new AddressFormatterForCN().createAddress(country));
}
}
}
Code from micro-service来自微服务的代码
@Inject
private Address address;
.....
listOfObjects.forEach(object -> responseAddressFormatter.addFormattedAddress(country));
When I want to start the microservice I did the following steps:当我想启动微服务时,我执行了以下步骤:
1. mvn clean install --> here I received BUILD SUCCESS
2. docker-compose build --> everything looks fine
3. docker-compose up ---> here I received this error:
Exception while loading the app: CDI deployment failure:WELD-001408: Unsatisfied dependencies for type Address with qualifiers @Default webapp_1 |加载应用程序时出现异常:CDI 部署失败:WELD-001408:带有限定符的地址类型的依赖项不满足 @Default webapp_1 | at injection point [BackedAnnotatedField] @Inject private在注入点 [BackedAnnotatedField] @Inject private
It looks like your Address bean is not getting scanned.看起来您的地址 bean 没有被扫描。 Are you sure you don't want to put any annotation on you Address class?您确定不想在地址 class 上添加任何注释吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.