SpringBoot configuration properties load priority order and

SpringBoot configuration properties load priority order and

  1. In your home directory (devtools when activated, compared with ~/.spring-boot-devtools.properties) Devtools global settings attributes.
  2. To use in the test @TestPropertySourcecomment.
  3. To use in the test propertiesproperties, it may be @SpringBootTestfor a testing application testing annotation portion.
  4. Command line parameters.
  5. From SPRING_APPLICATION_JSONproperty (embedding property system environment variable or system propert [] Inline JSON).
  6. ServletConfig Initialization parameters.
  7. ServletContext Initialization parameters.
  8. From java:comp/envJNDI property.
  9. Java system properties System.getProperties()( ).
  10. Operating system environment variables.
  11. Only random.*property RandomValuePropertySource.
  12. The application specified profile properties file (packaged in a jar of external application-{profile}.propertiesand YAML variable).
  13. The application specified profile properties file (inside the jar packaged application-{profile}.propertiesand YAML variable).
  14. In the jar outside the packaged application properties files ( application.propertiesand YAML variable).
  15. Inside the jar packaged applications properties files ( application.propertiesand YAML variable).
  16. In @Configurationthe class @PropertySourcenotes.
  17. The default attribute (using SpringApplication.setDefaultPropertiesspecified).

More add-ons in the smaller the number of loads about earlier, the higher the priority.

It is a common configuration properties 4,12,13,14,15,16

Reference: SpringBoot Chinese document https://docshome.gitbooks.io/springboot/content/

Published 27 original articles · won praise 1 · views 909

Guess you like

Origin blog.csdn.net/hu853996234/article/details/102639920