1.修改pom.xml文件
在pom.xml文件中的description属性后加入 war
pom文件中导入依赖
在这里插入代码片 <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>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
2.修改Applaction类
public class SchoolApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(SchoolApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(SchoolApplication.class);
}
3.第三步(项目启动后的操作)
当你添加依赖后在运行项目打印出
异常。解决办法:解决异常