IDEA + Springboot export jar package, war package

A, jar package export

Use the built-in Export tool will complain IDEA

1. Install maven

http://maven.apache.org/download.cgi

Download Binary zip archive

Configuration environment variable

"New System Variables" MAVEN_HOME enter the variable name, and the value of the variable is set to the installation path, here D: \ apache-maven-3.3.9

"Path variables", at the end of its variable value plus% MAVEN_HOME% \ bin (Note: with the previous value of the variable to English semicolon).

mvn -v view the installation is successful

2. Go to the directory project

mvn clean package

3. Generate jar package will target folder

Two, war package export (last visited path Ken will complain)

Pom.Xml Configuration

1.加入<packaging>war</packaging>

2. Join

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-tomcat</artifactId>

<! - packed bag when you can not go in, other facilities will be provided. In fact this dependency cycle theory can participate compile, test, run and so on.

                Equivalent to the compile , but the packing stage did exclude operation ->

<scope>provided</scope>

</dependency>

 

 

3. Join

<! - should the application.properties ( or application.yml) the context-path consistent ->

<finalName>patentManagementSystem</finalName>

 

 

Second, the new ServletInitializer class

 

 

import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

public class ServletInitializer extends SpringBootServletInitializer {
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }
}

三、 添加Artifact

 

 

改名去掉war;勾选show content of elements

 

删除WEB-INF

 

删除WETA-INF文件夹

 

(a)、就是静态文件资源 访问404

参考

https://blog.csdn.net/qq_32923745/article/details/78270835

Guess you like

Origin www.cnblogs.com/zuhaoran/p/11069560.html