In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the Springboot project start-up of how to use the command to dynamically specify the environment of the relevant knowledge, the content is detailed and easy to understand, the operation is simple and fast, with a certain reference value, I believe that everyone after reading this Springboot project start-up article on how to use the command to dynamically specify the environment will be rewarded, let's take a look.
Springboot startup uses commands to specify the environment
We all know that springboot's yml file can be configured with multiple environments, and you can specify which environment to use directly in application.yml.
For example: specify dev environment
This is written in the configuration file.
So, how do you specify dynamically when you start a project?
In fact, all you need to do is add one more command at startup:
Java-jar xxx.jar-- introduction to the spring.profiles.active=devSpringboot startup command
There are three ways for SpringBoot to start a project to specify commands
1. Add commands to the configuration file
Add the required commands to application.yml or application.properties
The figure is as follows: server.port=1118
2. Add java-jar thymeleaf.jar-- server.port=9000 in the startup command line
This way you can overwrite the contents of the original configuration file.
Note:
If it's followed by-- server.port=9000 's command. But after a successful start, it is still 1118.
The reason why the port has not changed is that SpringApplication does not pass in a deformable parameter (the second parameter) when it starts.
3. Add the command java-Dserver.port=9000-jar thymeleaf.jar to JVM
This way is to write the attribute directly into JVM, as a parameter of JVM, you can change the port number whether or not you add a second parameter to SpringBoot startup.
SpringBoot startup common command description-server.port specifies the server port-spring.profiles.active=dev specifies the running environment (usually dev, test, uat, prod)
Properties that can be configured in application.yml or application.properties can be passed in through the command.
This is the end of the article on "how to use commands to dynamically specify the environment when a Springboot project starts". Thank you for reading! I believe you all have a certain understanding of the knowledge of "how to use commands to dynamically specify the environment when the Springboot project starts". If you want to learn more, you are welcome to follow the industry information channel.
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.