1、添加两个依赖(在pom.xml中的添加war)
<!--加入这两个依赖以打包成war-->
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
<version>9.0.7</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<!--加入这两个依赖以打包成war-->
2、在springboot的启动类中添加一些代码
//继承类SpringBootServletInitializer并重写configure方法
public class BookstoreApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(BookstoreApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(BookstoreApplication.class, args);
}
}
3、在pom文件的parent同级标签下添加:
<packaging>war</packaging>
注: