问题
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