修改pom.xml文件

修改打包方式

修改pom.xml的packaging节点改 war

1
<packaging>war</packaging>

img

排除Tomcat容器

排除Spring Boot内置的Tomcat容器

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<!--移除嵌入式tomcat插件-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!--移除嵌入式tomcat插件-->
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--servlet-api的依赖-->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>

修改finalName节点

修改打包后的war包名(finalName节点)

1
2
3
4
5
6
7
8
9
<build>
<finalName>JXC</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

实现configure方法

启动类继承SpringBootServletInitializer类并实现configure方法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/**
* @author LeDao
*/
@SpringBootApplication
@MapperScan("com.ledao.mapper")
public class MyblogApplication extends SpringBootServletInitializer {

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(MyblogApplication.class);
}

public static void main(String[] args) {
SpringApplication.run(MyblogApplication.class, args);
}
}

打包

用idea打包,点击idea的Maven图形界面的package

img