简体   繁体   中英

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

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 .

原来,该问题是错误的配置,该问题已解决,方法是从云配置bootstrap.yml中指定的应用程序名称中删除所有特殊字符。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM