1、pom.xnl中添加配置:
<packaging>war</packaging>
2、pom.xml中添加配置:
spring-boot-starter-web中会包含tomcat,单独设置tomcat的scope为provided,打包时则不会将tomcat打入war包。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
3、修改Application文件或者增加servletInitializer
采用web3.0 规范,没有web.xml ,使用此类实现web.xml的的作用。
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication
public class XiaoBoot01Application extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(XiaoBoot01Application.class);
}
public static void main(String[] args) {
SpringApplication.run(XiaoBoot01Application.class, args);
}
}