@ConfigurationProperties、@Value、@PropertySource

@ConfigurationProperties (spring-boot the dependent), @ Value (spring-beans under dependent), @ PropertySource (spring-context dependent case)

@ConfigurationProperties use

get and set methods have to write

test

@Value use

Do not write to get and set methods

@PropertySource use 

@PropertySouce used to reference a custom .properties properties file

Can be combined @ConfigurationProperties use, also you need to write the get and set methods

Can also be combined @Value use, no need to write the same get and set methods

 

Guess you like

Origin www.cnblogs.com/yanguobin/p/11598161.html