栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何在Tomcat服务器上部署Spring Boot Web应用程序

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何在Tomcat服务器上部署Spring Boot Web应用程序

这是有关如何将

Spring Boot
应用程序部署为
war
文件的两个很好的文档。

你可以按照此spring启动howto-traditional-deployment 文档

根据此文档的步骤-

  1. 你将应用程序的主类更新为extend

    SpringBootServletInitializer

  2. 下一步是更新构建配置,以便你的项目生成war文件而不是jar文件。

    <packaging>war</packaging>

  3. 将嵌入式Servlet容器的相关性标记为已提供。

<dependency>    <groupId>org.springframework.boot</groupId>    <artifactId>spring-boot-starter-tomcat</artifactId>    <scope>provided</scope></dependency>

还有另一种方法

请参阅此spring io文档,其中概述了如何将spring boot app部署到应用程序服务器。

Steps

  1. jar
    包装更改为
    war

  2. spring-boot-maven-plugin
    在你的插件中注释掉插件的声明pom.xml

  3. 通过扩展

    SpringBootServletInitializer
    和覆盖
    configure
    方法将Web入口点添加到你的应用程序中

  4. 删除

    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
依存度将包括那些依赖条件。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/411289.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号