How to bind Spring cloud config values to @ConfigurationProperties object?

这一生的挚爱 提交于 2019-12-12 04:06:14

问题


I am trying to populate a @ConfigurationProperties-annotated class with properties from a yaml file on my cloud config server (Jhipster registry, specifically).

The application is connecting to the server and reading the correct file, as when either the server or the file is unavailable, I get an exception either for the missing host or an unexpected empty file.

However, I cannot access any of the properties in the file.

I am primarily trying to populate a @ConfigurationProperties object, but all of the fields are null.

Additionally, trying to use @Value for any of the properties in the file throws an error as the property placeholders aren't found.

I've set the spring.cloud.config.name and profile values to match the format expected according to the JHipster docs.


回答1:


The issue turned out to be an erroneous configuration, the problem was resolved by removing all special characters from the application name specified in the cloud config bootstrap.yml.



来源:https://stackoverflow.com/questions/45683050/how-to-bind-spring-cloud-config-values-to-configurationproperties-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!