这是有关如何将
Spring Boot应用程序部署为
war文件的两个很好的文档。
你可以按照此spring启动howto-traditional-deployment 文档
根据此文档的步骤-
你将应用程序的主类更新为extend
SpringBootServletInitializer
。下一步是更新构建配置,以便你的项目生成war文件而不是jar文件。
<packaging>war</packaging>
将嵌入式Servlet容器的相关性标记为已提供。
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope></dependency>
还有另一种方法
请参阅此spring io文档,其中概述了如何将spring boot app部署到应用程序服务器。
Steps
将
jar
包装更改为war
。spring-boot-maven-plugin
在你的插件中注释掉插件的声明pom.xml通过扩展
SpringBootServletInitializer
和覆盖configure
方法将Web入口点添加到你的应用程序中删除
spring-boot-starter-tomcat dependency
和修改你的spring-boot-starter-web
依赖项
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </exclusion> </exclusions></dependency>
在中
pom.xml,删除
spring-beans和
spring-webmvc依赖项。该
spring-boot-starter-web依存度将包括那些依赖条件。



