Home Java javaTutorial How to package springboot into a jar package in maven

How to package springboot into a jar package in maven

May 17, 2023 am 08:19 AM
jar maven springboot

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!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to run jar files in Linux How to run jar files in Linux Feb 20, 2024 am 10:40 AM

Prerequisites for running JAR files Running JAR files on a Linux system requires the installation of the Java Runtime Environment (JRE), which is the basic component required to execute Java applications, including the Java Virtual Machine (JVM), core class libraries, etc. Many mainstream Linux distributions, such as Ubuntu, Debian, Fedora, openSUSE, etc., provide software libraries of JRE packages to facilitate user installation. The following article will detail the steps to install JRE on popular distributions. After setting up the JRE, you can choose to use the command line terminal or the graphical user interface to start the JAR file according to your personal preference. Your choice may depend on familiarity with Linux shells and personal preference

Java Maven build tool advancement: optimizing compilation speed and dependency management Java Maven build tool advancement: optimizing compilation speed and dependency management Apr 17, 2024 pm 06:42 PM

Optimize Maven build tools: Optimize compilation speed: Take advantage of parallel compilation and incremental compilation. Optimize dependencies: Analyze dependency trees and use BOM (bill of materials) to manage transitive dependencies. Practical case: illustrate optimizing compilation speed and dependency management through examples.

Avoid common mistakes in Maven environment configuration: Solve configuration problems Avoid common mistakes in Maven environment configuration: Solve configuration problems Feb 19, 2024 pm 04:56 PM

Maven is a Java project management and build tool that is widely used in the development of Java projects. In the process of using Maven to build projects, you often encounter some common environment configuration problems. This article will answer these common questions and provide specific code examples to help readers avoid common configuration errors. 1. Maven environment variables are incorrectly configured. Problem description: When using Maven, if the environment variables are incorrectly configured, Maven may not work properly. Solution: Make sure

Guide to setting up Maven local libraries: efficiently manage project dependencies Guide to setting up Maven local libraries: efficiently manage project dependencies Feb 19, 2024 am 11:47 AM

Maven local warehouse configuration guide: Easily manage project dependencies. With the development of software development, project dependency package management has become more and more important. As an excellent build tool and dependency management tool, Maven plays a vital role in the project development process. Maven will download project dependencies from the central warehouse by default, but sometimes we need to save some specific dependency packages to the local warehouse for offline use or to avoid network instability. This article will introduce how to configure Maven local warehouse for easy management

Maven Advanced Tutorial: In-depth exploration of various methods of Jar package import Maven Advanced Tutorial: In-depth exploration of various methods of Jar package import Feb 23, 2024 pm 02:57 PM

Title: Maven Advanced Tutorial: In-depth exploration of various methods of Jar package import. As a Java project management tool, Maven is widely used in project construction, dependency management, etc. In the actual development process, we often use Jar packages of various third-party libraries, and how to effectively import Jar packages has become a skill that must be mastered. This article will delve into the methods of importing Jar packages in Maven, including using local Jar packages, remote warehouse Jar packages, and custom Jar packages, and give specific details.

Detailed explanation of Maven Alibaba Cloud image configuration Detailed explanation of Maven Alibaba Cloud image configuration Feb 21, 2024 pm 10:12 PM

Detailed explanation of Maven Alibaba Cloud image configuration Maven is a Java project management tool. By configuring Maven, you can easily download dependent libraries and build projects. The Alibaba Cloud image can speed up Maven's download speed and improve project construction efficiency. This article will introduce in detail how to configure Alibaba Cloud mirroring and provide specific code examples. What is Alibaba Cloud Image? Alibaba Cloud Mirror is the Maven mirror service provided by Alibaba Cloud. By using Alibaba Cloud Mirror, you can greatly speed up the downloading of Maven dependency libraries. Alibaba Cloud Mirror

A complete guide to installing and configuring Maven on Mac systems A complete guide to installing and configuring Maven on Mac systems Jan 28, 2024 am 09:42 AM

Detailed explanation of the methods and techniques of installing Maven on Mac system. As a developer, installing Maven on Mac system is a very common requirement, because Maven is a very popular build tool for managing the dependencies and build process of Java projects. This article will introduce in detail the methods and techniques of installing Maven on Mac system, and provide specific code examples. 1. Download Maven first, you need to download it from the official website (https://maven.apache.org/down

Guide you to set up a Maven local repository to speed up project construction Guide you to set up a Maven local repository to speed up project construction Feb 24, 2024 pm 02:12 PM

Teach you step by step how to configure Maven local warehouse: improve project construction speed Maven is a powerful project management tool that is widely used in Java development. It can help us manage project dependencies, build projects, and publish projects, etc. However, during the actual development process, we sometimes encounter the problem of slow project construction. One solution is to configure a local repository to improve project build speed. This article will teach you step by step how to configure the Maven local warehouse to make your project construction more efficient. Why do you need to configure a local warehouse?

See all articles