Home > Java > javaTutorial > body text

How to package springboot into a jar package in maven

WBOY
Release: 2023-05-17 08:19:44
forward
1404 people have browsed it

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>
Copy after login
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
Copy after login

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
Copy after login
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
Copy after login

You can also choose to read different configuration files at startup

nohup java -jar target/xxx.jar &
Copy after login
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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template