"Maven" Project Package-war package-jar Package [idea to make the project into a war package]

Source: Internet
Author: User

Reprint please indicate the source: http://blog.csdn.net/qq_26525215

This article originates from "University trip------familiar with the blog of Memory"

First, the project must be a MAVEN-configured project.

Added a publishing plug-in to implement it.
Add the following code to the Pom.xml of the project:

<?xml version= "1.0" encoding= "UTF-8"?> <project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "HTT" P://www.w3.org/2001/xmlschema-instance "xsi:schemalocation=" http://maven.apache.org/POM/4.0.0 Http://maven.apach
    E.org/xsd/maven-4.0.0.xsd "> <modelVersion>4.0.0</modelVersion> ... <!--here are the packages that make the item a suffix If modified to jar, it is packaged into jar package--> <packaging>war</packaging> ... <build> <plugin S> <!--Below is the add-on--> <plugin> <groupid>org.springframe that will be used to package the application for release. Work.boot</groupid> <artifactId>spring-boot-maven-plugin</artifactId> &L T;executions> <execution> <goals> &
                Lt;goal>repackage</goal> </goals> </execution> </executions>
            </plugin> </plugins> </build> </project> 

Added a packaged plug-in: Spring-boot-maven-plugin, and added a one-line configuration:

<packaging>war</packaging>

This line of configuration specifies that the application project be packaged into a war file.

This allows you to add a packaged configuration to the idea, open the Run/debug Configurations dialog box, and select Add Configure a MAVEN package project

Select the root directory for the project in the working directory, enter package on the command line, and save the configuration as package

Now the target directory for the project is this:

To run the package package project, you can package the instance project, and the packaged file will be exported to the project target file

Then, we look at the project's target directory:

You can also package it directly with the MAVEN command. Open a command line window, switch the path to the project and directory, directly in the command line input MAV package, the same can be implemented to package into the war.

If you need to package into a jar, you can not write

<packaging>war</packaging>

This sentence, can also be written

<packaging>jar</packaging>

If you are packing a war file, place the war file in Tomcat's WebApp path when the package is complete, and start Tomcat to run the program automatically.

If you package the jar file, if packaged in the project's target directory to generate the jar file as: Springboothellom-1.0-snapshot.jar.
Switch to the target directory in the Command Line window and run the following command to start the application:

Java-jar Springboothellom-1.0-snapshot.jar
Idea packs a project into a war package

After selection:

Tick bulid on

Then you need to compile:



You can then see:

This article is written by [familiar memory], all rights reserved.
Welcome to reprint, sharing is the source of progress.

Reprint please indicate the source: http://blog.csdn.net/qq_26525215

This article originates from "University trip------familiar with the blog of Memory"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.