我已经将扩展从quarkus 2.7.5
迁移到了quarkus 2.8.0
。
迁移之后,我运行mvn clean install
,控制台显示了关于所有(可能是100个)配置属性的奇怪警告(其中一些属性是由我定义的,还有一些不像java.specification.version):
[WARNING] [io.quarkus.config] Unrecognized configuration key "my.property" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
我认为我的集成测试模块导致了这个问题。以下是我在运行时文件夹中的类:
import java.util.Optional;
import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
@ConfigRoot(phase = ConfigPhase.RUN_TIME, prefix="", name = "myApp")
public class MyAppConfig {
@ConfigItem(defaultValue = "defaultValue")
String firstProperty;
@ConfigItem(defaultValue = "")
Optional<String> secondProperty;
@ConfigItem(defaultValue = "defaultValue")
String thirdProperty;
// Getters ...
}
这是我的测试:
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.junit.jupiter.api.Test;
import io.quarkus.test.junit.QuarkusTest;
@QuarkusTest
public class MyAppIntegrationTest {
@ConfigProperty(name="myApp.first-property")
String firstProperty;
@ConfigProperty(name="myApp.second-property")
String secondProperty;
@ConfigProperty(name="myApp.third-property")
String thirdProperty;
@Test
public void testConfig() {
assertEquals("firstValue", firstProperty);
assertEquals("secondValue", secondProperty);
assertEquals("thirdValue", thirdProperty);
}
}
有人能帮我吗?例如,我需要一个BuildItem吗?
谢谢你的帮忙
发布于 2022-05-25 07:27:41
在对这些警告花了几个小时之后,我发现这些警告是由ConfigRoot
注释的空前缀字段引起的。
将名称字段设置为""
,前缀设置为"myApp"
解决了问题
https://stackoverflow.com/questions/72350550
复制相似问题