大家!
您能否就此类问题给我建议。
我有一个简单的测试项目,以便使用 Microprofile 配置进行测试。
我测试的测试类的字段:
@Inject
@ConfigProperty(name = "injected.value")
private String injectedValue;
这是我的 pom 的依赖项部分:
<dependencies>
<!-- https://mvnrepository.com/artifact/org.eclipse.microprofile/microprofile -->
<dependency>
<groupId>org.eclipse.microprofile</groupId>
<artifactId>microprofile</artifactId>
<version>3.3</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
</dependencies>
我发动 war ,然后:
1.当我将war部署到tomee 8.0.1-microprofile(tomee-maven-plugin,tomeeClassifier设置为microprofile)时 -> 然后一切正常。
2.但是当我将war部署到tomee 8.0.1-plus(tomee-maven-plugin,tomeeClassifier设置为plus)时 -> 然后我得到了异常:
org.apache.webbeans.exception.WebBeansDeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Api type [java.lang.String] is not found with the qualifiers
Qualifiers: [@org.eclipse.microprofile.config.inject.ConfigProperty(name=injected.value, defaultValue=org.eclipse.microprofile.config.configproperty.unconfigureddvalue)]
for injection into Field Injection Point, field name : injectedValue, Bean Owner : ...
更多情况下,当我将 pom 依赖项更改为:
时,情况 1(部署到 tomee 8.0.1-microprofile)<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>8.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile.config</groupId>
<artifactId>microprofile-config-api</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
我收到错误:
org.apache.webbeans.exception.WebBeansDeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Api type [java.lang.String] is not found with the qualifiers
Qualifiers: [@org.eclipse.microprofile.config.inject.ConfigProperty(name=injected.value, defaultValue=org.eclipse.microprofile.config.configproperty.unconfigureddvalue)]...
请问有人可以帮我解决这个问题吗?
我需要在产品中使用 Microptofile,但目前还做不到。
最佳答案
要使 plus 和 plume 版本正常工作,您必须在 system.properties 中包含以下属性:
tomee.mp.scan = 全部
另一种方法是使用 tomee 插件并在 pom.xml 中添加此属性:
<systemVariables>
<tomee.mp.scan>all</tomee.mp.scan>
</systemVariables>
关于ejb - Tomee+Microprofile UnsatisfiedResolutionException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60932960/