How to package springboot into jar package in maven
Most people do not understand the knowledge points of this article "how to make springboot into a jar package in maven", so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to make springboot into a jar package in maven" article.
Maven's command:
1.mvn clean package-DskipTests: run this command in the project directory and generate the jar package or war package in the target directory.
2.mvn clean: clean up the temporary files produced by the project, usually the target directory under the module
3.mvn compile-DskipTests: the module installation command copies the packaged jar/war file to your local repository for other modules to use-Dmaven.test.skip=true to skip the test (and skip test compile).
4.mvn test: test commands, or execute test cases for junit under src/test/java/.
5.mvn deploy: issue a command to publish the packaged file to a remote reference and provide other people with download dependencies, usually to the company's private server.
If it is a maven plus springboot project, add a plug-in to the pom.xml file in the project
Org.springframework.boot spring-boot-maven-plugin
Ps: here's how to package a spring boot project with maven and pack it into a jar package
If you are using maven to manage the project, execute the following command
The cd project mvn clean package## with the directory (at the same level as pom.xml) or execute the following command # # to package mvn clean package-Dmaven.test.skip=true after excluding the test code
You can also package directly in eclipse, as follows:
Right-select the project Run As-- > Maven build...
Enter the maven command here:
Clean package-Dmaven.test.skip=true
Seeing BUILD SUCCESS indicates success. After packaging, the jar package will be generated to the target directory, which is usually named project name + version number. Jar
Start the jar package command
Java-jar target/xxx.jar
In this way, as long as the console is closed, the service cannot be accessed. Let's start it by running in the background: (linux environment only)
Nohup java-jar target/xxx.jar &
You can also choose to read different configuration files at startup
Java-jar xxx.jar-- spring.profiles.active=dev
You can also set the jvm parameter at startup
The above is about the content of this article on "how to make springboot into jar package in maven". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more related knowledge, please pay attention to the industry information channel.