Spring Boot application.properties value not populating

后端 未结 8 558
孤街浪徒
孤街浪徒 2020-12-04 11:41

I have a very simple Spring Boot app that I\'m trying to get working with some externalised configuration. I\'ve tried to follow the information on the spring boot documenta

8条回答
  •  长情又很酷
    2020-12-04 12:26

    The user "geoand" is right in pointing out the reasons here and giving a solution. But a better approach is to encapsulate your configuration into a separate class, say SystemContiguration java class and then inject this class into what ever services you want to use those fields.

    Your current way(@grahamrb) of reading config values directly into services is error prone and would cause refactoring headaches if config setting name is changed.

提交回复
热议问题