gpt4 book ai didi

java - 向 JHipster Cloud application.yml 添加属性导致注册表配置失败

转载 作者:行者123 更新时间:2023-12-02 12:20:14 25 4
gpt4 key购买 nike

我想将自定义属性添加到我的云配置的 application.yml 中。文件中的注释说它适用于所有共享配置。但是,当我这样做时,它会导致属性与 JHipsters 自己的 ApplicationProperties 的绑定(bind)失败,因为该类没有正确的可写属性。

应用程序.yml

application:
clients:
- Foo

堆栈跟踪:

Caused by: org.springframework.boot.bind.RelaxedBindingNotWritablePropertyException: Failed to bind 'application.clients[0]' from 'file:central-config/localhost-config/application.yml' to 'clients[0]' property on 'io.github.jhipster.registry.config.ApplicationProperties'

最佳答案

来自 JHipster 的文档:

Application-specific properties Your generated application can also have its own Spring Boot properties. This is highly recommended, as it allows type-safe configuration of the application, as well as auto-completion and documentation within an IDE.

JHipster has generated a ApplicationProperties class in the config package, which is already preconfigured, and it is already documented at the bottom the application.yml, application-dev.yml and application-prod.yml files. All you need to do is code your own specific properties. (emphasis mine)

您是否已完成该步骤并将您自己的属性添加到 ApplicationProperties.java ?看起来您应该拥有 List<String> clients 类型的属性。如果没有,这就是它失败的原因,因为它试图将配置属性绑定(bind)到 ApplicationProperties类,但该类不包含存储它的属性。

关于java - 向 JHipster Cloud application.yml 添加属性导致注册表配置失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45844398/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com