Using Expressions in Spring application.properties file

前端 未结 3 2212
梦毁少年i
梦毁少年i 2020-12-06 18:32

Can expressions be used as a right-hand-side value in a Spring application.properties file?

For example, something like this:

logging.level.com.acme=         


        
3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-06 19:02

    No this is not possible, From spring boot reference:

    Feature @ConfigurationProperties

    SpEL evaluation No

    Instead you can have an application-default.properties in production and in it define loglevel=WARN. And in your application.properties:

    loglevel=DEBUG
    logging.level.com.acme=${loglevel}
    

    The profile-specific properties file(-default by default) should override the properties from application.properties, more info here.

提交回复
热议问题