这是有关如何将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
依存度将包括那些依赖条件。