In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how the springboot project runs with the jar package". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to run the springboot project with the jar package".
I. pom file configuration
1. Change the packing method to jar
Jar
2. Configure the maven plug-in for executable jar packages
Org.springframework.boot spring-boot-maven-plugin true
3. Introduce external jar dependencies (optional)
If an external jar is introduced into the project, you can create a lib folder in the project root directory and place the jar package in the lib:
Then introduce the jar package into the pom file:
PS: if the project is packaged as war and external jar is introduced, the configuration of the maven plug-in is as follows
Org.apache.maven.plugins maven-war-plugin 2.6$ {project.basedir} / lib WEB-INF/lib * * / * .jar II Package operation
1. Packing
The packaging command is simple:
Mvn install
2. Run
In production and test environments, it is generally necessary to keep the process running in the background and disconnect the terminal without interruption, then you need to execute the following command:
Nohup java-jar test.jar & > > log.out & III. Configuration file priority
Spring boot looks for the configuration files in the following order:
1. Under the / config folder of "current directory"
2. Under the "current directory"
3. Under the / config folder of classpath
4. Under classpath
Note:
The current directory refers to the directory where the java command is executed. If the java command is executed through the shell script, the current directory refers to the directory where the shell script is located. If you cd to a directory and then execute the java command in the shell script, the current directory refers to the directory after cd.
Different priority profiles can be read, but the configuration of the same configuration item, the configuration of the high priority profile will overwrite the configuration of the low priority profile.
The configuration file in the jar package is not easy to modify. In production, we usually put the configuration file outside the jar package.
In production, you can directly place the configuration file in the config directory at the same level as the directory where the jar package is located, then cd to the directory where the jar package is located in the script, and execute the java command to read the configuration file.
Thank you for your reading, the above is the content of "how to run the springboot project with the jar package". After the study of this article, I believe you have a deeper understanding of how the springboot project runs with the jar package, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.