【问题标题】:how to mapping nested object configuration in yaml quarkus如何在 yaml quarkus 中映射嵌套对象配置
【发布时间】:2021-02-02 09:00:42
【问题描述】:

如何将 application.yml 映射到配置文件?

我在 application.yml 中有配置

games-config:
  config:
   -  variation-number: 6
       game-name: Match the shadow
       number-of-items: 5
   -  variation-number: 5
      game-name: Drag object to matching Basket
      number-of-items: 4
   -  variation-number: 5
      game-name: Re arrange the words
      number-of-items: 0
   -  variation-number: 5

我尝试用这个映射`

public class GameConfig {
    public Integer variationNumber;
    public String gameName;
    public Integer numberOfItems;
} 

@ConfigProperties(prefix = "games-config")
public class GamesListConfig {
    @ConfigProperty(name = "config")
    public List<GameConfig> config;
}

但我总是遇到这样的错误: enter image description here

【问题讨论】:

  • 您使用的是哪个 Quarkus 版本?上一个版本应该支持这个。
  • 我使用 quarkus 版本 1.10.5.Final
  • 你可以试试 1.11.1.Final 吗?它应该适用于该版本。
  • 是的,我试过了,它的工作原理!谢谢你

标签: java quarkus configmap


【解决方案1】:

这需要 Quarkus 版本 1.11.x。以前的版本不支持具有复杂对象类型的列表。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-09-27
    • 2013-08-01
    • 2017-05-18
    • 2021-09-30
    • 2017-09-11
    • 2018-06-03
    • 1970-01-01
    相关资源
    最近更新 更多