springboot 实现了“嵌入式”思想,可以直接通过指令 java -jar xxxxx.jar 发布一个应用。
但有些情况下,我们更希望能通过外置的tomcat来发布该应用。
Maven文件pom.xml中
<packaging>war</packaging>
<!--部署成war包时开启↓↓↓↓--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> <!--provided表明该包只在编译和测试的时候用--> </dependency> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> <scope>provided</scope> <!--provided表明该包只在编译和测试的时候用--> </dependency> <!--部署成war包时开启↑↑↑↑-->
然后直接maven 打包package
搞定