【问题标题】:How to deploy (and access) SpringBoot war with Tomcat? (using Getting started guide)如何使用 Tomcat 部署(和访问)Spring Boot 战争? (使用入门指南)
【发布时间】:2015-03-27 23:52:51
【问题描述】:

如何创建(和访问)基于 Serving Web Content with Spring MVC guide 的可部署战争?

感觉步骤都成功了,但是当尝试查看页面时,返回 404 错误...可能我只是尝试访问错误的 url?

本教程在创建和运行 jar 时效果很好,但是当我尝试从战争中访问网页时,会导致 404 错误。

第 1 步。Create a deployable war file

  • 使Application类扩展SpringBootServletInitializer
  • 这会导致Packaging executable jar and war files,这涉及更改打包标签,并将嵌入式容器依赖项标记为“已提供”
  • 使用 mvn package 打包 war 文件

第 2 步。部署!

  • 将 gs-serving-web-content-0.1.0.war 复制到 Tomcat 的 webapps 目录中
  • Tomcat 然后创建目录 gs-serving-web-content-0.1.0
  • Tomcat 控制台说: deployWAR INFO: Deployment of web application archive C:\Programs\apache-tomcat-7.0.56\web apps\gs-serving-web-content-0.1.0.war has finished in 2,746 ms

第 3 步。查看网页(这就是问题所在)

任何帮助将不胜感激!

【问题讨论】:

    标签: tomcat spring-boot war


    【解决方案1】:

    http://localhost:8080/gs-serving-web-content-0.1.0/greeting?name=AAA 是应该可以使用的 URL,但听起来您的 Boot 应用程序尚未启动。如果它已经启动,你会在 Tomcat 的控制台日志中看到 Boot 的通常输出。

    我猜它还没有开始,因为你没有告诉你的SpringBootServletInitializer 子类你的应用程序的配置类。你是否覆盖了configure?它应该看起来像这样:

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(YourApplication.class);
    }
    

    【讨论】:

      猜你喜欢
      • 2019-03-21
      • 2015-10-28
      • 2019-03-23
      • 1970-01-01
      • 2019-10-27
      • 1970-01-01
      • 2017-09-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多