Home  >  Article  >  Java  >  How to package springboot into a jar package in maven

How to package springboot into a jar package in maven

WBOY
WBOYforward
2023-05-17 08:19:441399browse

Maven command:

1.mvn clean package -DskipTests: Run this command in the project directory to generate a jar package or war package in the target directory.

2.mvn clean: Clean 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 warehouse for use by other modules -Dmaven.test.skip=true skips testing (test compile will also be skipped).

4.mvn test: test command, or execute src/test Test cases for junit under /java/.

5.mvn deploy: Publish command to publish the packaged files to remote reference and provide other personnel with download dependencies, usually to the company's private server.

If it is a maven plus springboot project, the plug-in must be added to the pom. Make it into a jar package

If you are using maven to manage the project, just execute the following command

<plugin>
 <groupid>org.springframework.boot</groupid>
 <artifactid>spring-boot-maven-plugin</artifactid>
</plugin>
You can also package it directly in eclipse, the steps are as follows:


Right-click the project and select Run As-->Maven build...How to package springboot into a jar package in maven

Enter the maven command here:How to package springboot into a jar package in maven

cd 项目跟目录(和pom.xml同级)
mvn clean package
## 或者执行下面的命令
## 排除测试代码后进行打包
mvn clean package -Dmaven.test.skip=true

Seeing BUILD SUCCESS indicates success. After packaging is completed, the jar package will be generated in the target directory. The name is usually the project name and version number.jarHow to package springboot into a jar package in maven

Start jar package commandHow to package springboot into a jar package in maven

clean package -Dmaven.test.skip=true
In this way, as long as the console is closed, the service cannot be accessed. Below we use the method of running in the background to start: (Linux environment only)

java -jar target/xxx.jar

You can also choose to read different configuration files at startup

nohup java -jar target/xxx.jar &
You can also Set jvm parameters at startup

The above is the detailed content of How to package springboot into a jar package in maven. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete