spring boot war包部署到外部tomcat
1.修改pom文件里的打包方式为war包格式
2.添加tomcat依赖的scope为provide
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provide</scope>
</dependency>
3.使Application启动类继承 SpringBootServletInitializer并重写其configure方法。
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application){
return application.sources(XxxApplication.class);
}
4.利用maven进行打包,将打好的war包放入tomcat的webapps目录下
5.启动tomcat,如果出现错误NoClassFound el .......LifeCycleException,这个是因为jar包冲突,需要将idea下的el-api.jar拷贝到tomcat的lib目录下。替换完成后重启tomcat即可。

浙公网安备 33010602011771号