首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >迁移到Quarkus 2.8.0后有关config属性的警告

迁移到Quarkus 2.8.0后有关config属性的警告
EN

Stack Overflow用户
提问于 2022-05-23 14:49:33
回答 1查看 133关注 0票数 0

我已经将扩展从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

我认为我的集成测试模块导致了这个问题。以下是我在运行时文件夹中的类:

代码语言:javascript
运行
复制
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 ...

    
}

这是我的测试:

代码语言:javascript
运行
复制
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吗?

谢谢你的帮忙

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-05-25 07:27:41

在对这些警告花了几个小时之后,我发现这些警告是由ConfigRoot注释的空前缀字段引起的。

将名称字段设置为"",前缀设置为"myApp"解决了问题

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72350550

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档