SpringBoot打成war包部署到tomcat
1.pom.xml依赖
如果没有web的依赖需要添加
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
启动类实现类依赖
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
打包方式
<packaging>war</packaging>
打包后包名
<build>
<finalName>eladmin</finalName>
</build>
2.修改启动类
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
继承SpringBootServletInitializer类,实现下面方法:
// 不重写打包war部署到tomcat接口会报404
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(AppRun.class);
}