@ConfigurationProperties vs. @Value

@ConfigurationProperties vs. @Value

If you define a set of configuration keys for your own components, we recommend you group them in a POJO annotated with @ConfigurationProperties. Doing so will provide you with structured, type-safe object that you can inject into your own beans.

SpEL expressions from application property files are not processed at time of parsing these files and populating the environment. However, it is possible to write a SpEL expression in @Value. If the value of a property from an application property file is a SpEL expression, it will be evaluated when consumed via @Value.

喜欢关注一下,不喜欢点评一下
原文地址:https://www.cnblogs.com/chengmuyu/p/15302364.html