PropertySource order

Spring Boot using a very special PropertySource sequence which is intended to permit a reasonable coverage value. Property is considered in the following order:

$ HOME / .config / spring-boot when devtools is active, Devtools global folder set properties.

@TestPropertySource Notes test.

The attribute properties test. Test notes and annotations can be used in a specific portion @SpringBootTest test application.

Command line parameters.

Properties SPRING_APPLICATION_JSON (embedded environment variable or system attributes embedded JSON) from the.

ServletConfig initialization parameters.

ServletContext initialization parameters.

The JNDI properties java: comp / env.

Java system properties (System.getProperties ()).

Operating system environment variables.

A RandomValuePropertySource, only has a performance random. *.

Packaged jar (application- {profile} .properties YAML and variants thereof) other than a specific application properties in the profile.

Packaged in a jar is application-specific properties of the profiles (application- {profile} .properties YAML and variants).

Packaged outside of jar application properties (the application.properties YAML and variants).

Packaged in a jar in the application properties (the application.properties YAML and variants).

@ Comment on PropertySource @ Configuration class. Please note, Environment before refreshing the application context, such property will not be added to the source. Now configure some properties (such as logging. And spring.main. To read before the refresh start) too late.

Default properties (specified by setting SpringApplication.setDefaultProperties).

Guess you like

Origin www.cnblogs.com/Johar/p/12000167.html