In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article focuses on "what is the priority of SpringBoot configuration". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "what is the priority of SpringBoot configuration?"
The official document in SpringBoot is called Externalized Configuration:
The priorities are as follows:
(1) Devtools global settings properties in the $HOME/.config/spring-boot folder when devtools is active.
(2) @ TestPropertySource annotations on your tests.
(3) properties attribute on your tests. Available on @ SpringBootTest and the test annotations for testing a particular slice of your application.
(4) Command line arguments.
(5) Properties from SPRING_APPLICATION_JSON (inline JSON embedded in an environment variable or system property)
(6) ServletConfig init parameters.
(7) ServletContext init parameters.
(8) JNDI attributes from java:comp/env.
(9) Java System properties (System.getProperties ())
(10) OS environment variables.
(11) A RandomValuePropertySource that has properties only in random.*.
(12) Profile-specific application properties outside of your packaged jar (application- {profile} .properties and YAML variants)
(13) Profile-specific application properties packaged inside your jar (application- {profile} .properties and YAML variants)
14) Application properties outside of your packaged jar (application.properties and YAML variants).
(15) Application properties packaged inside your jar (application.properties and YAML variants).
(16) @ PropertySource annotations on your @ Configuration classes Please note that such property sources are not added to the Environment until the application context is being refreshed. This is too late to configure certain properties such as logging.* and spring.main.* which are read before refresh begins.
(17) Default properties (specified by setting SpringApplication.setDefaultProperties)
To do an experiment, in run as configuration, program argument is set to server.port=8001
The Environment environment variable is set to server.port=8002.
The Application.properties file inside the SpringBoot project is set to 8000:
When the last run time, the effective port is 8002 set by the environment variable:
Setting environment variables using the set command in shell also works as expected:
At this point, I believe you have a deeper understanding of "what is the priority of SpringBoot configuration". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.