1 在pom.xml中将打包形式 jar 修改为war <packaging>war</packaging>
构建项目名称 <finalName>xdclass_springboot</finalName>
例如:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.taobao</groupId>
<artifactId>test_project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<!-- 改动1 打包方式 -->
<packaging>war</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<!-- 改动2 打包的项目名称 -->
<finalName>xdclass_springboot</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
2 修改启动类
public class TestclassApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(TestclassApplication.class);
}
public static void main(String[] args) throws Exception {
SpringApplication.run(TestclassApplication.class, args);
}
}
3 打包项目,放入tomcat目录中,并启动tomcat