How to package springboot into a jar package in maven
May 17, 2023 am 08:19 AMMaven 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...
Enter the maven command here:
cd?項目跟目錄(和pom.xml同級) mvn?clean?package ##?或者執(zhí)行下面的命令 ##?排除測試代碼后進行打包 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.jar
Start jar package command
clean?package?-Dmaven.test.skip=trueIn 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!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

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

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.

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

When using Maven to build a Java project, you often encounter situations where you need to set the Java version. Correctly setting the Java version can not only ensure that the project runs normally in different environments, but also avoid some compatibility issues and improve the stability and maintainability of the project. This article will introduce the best practices and recommended methods for setting Java versions in Maven, and provide specific code examples for reference. 1. Set the Java version in the pom.xml file. In the pom.xml file of the Maven project, you can

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

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

IDEA (IntelliJIDEA) is a powerful integrated development environment that can help developers develop various Java applications quickly and efficiently. In Java project development, using Maven as a project management tool can help us better manage dependent libraries, build projects, etc. This article will detail the basic steps on how to create a Maven project in IDEA, while providing specific code examples. Step 1: Open IDEA and create a new project Open IntelliJIDEA

Smooth build: How to correctly configure the Maven image address When using Maven to build a project, it is very important to configure the correct image address. Properly configuring the mirror address can speed up project construction and avoid problems such as network delays. This article will introduce how to correctly configure the Maven mirror address and give specific code examples. Why do you need to configure the Maven image address? Maven is a project management tool that can automatically build projects, manage dependencies, generate reports, etc. When building a project in Maven, usually
