【问题标题】:Error deploying the example application (Spring Boot 1.3.4, JSP, WAR Packaging) at Pivotal Cloud Foundry using STS使用 STS 在 Pivotal Cloud Foundry 部署示例应用程序(Spring Boot 1.3.4、JSP、WAR 打包)时出错
【发布时间】:2016-05-07 14:09:39
【问题描述】:

我跟随 this blog post 使用 Boot DashboardSpring example application 部署到 Pivotal Cloud Foundry。示例应用程序是一个 Spring Boot 应用程序(1.3.2.RELEASE),使用 JSP 并具有 WAR 封装。

应用程序似乎启动正常,但主页是空白的。尝试 cURL,我看到了以下输出:

但是,当我使用命令行部署应用程序时:

cf push np-spring-tutorial -p spring-tutorial-0.0.1-SNAPSHOT.war

应用程序已部署并运行良好。

那么,是不是 Boot Dashboard 部署到 PWS 的方式还不支持带有 JSP 的 WAR 文件?在使用 Boot Dashboard 部署 JSP 少 JAR 文件之前,我曾尝试过,它们运行良好。

更新:

根据 Sanjay Rawat 的建议,我将 Spring Boot 版本更新为 1.3.4,并且现在还有一个 manifest.yml,如下所示:

---
applications:
- name: np-spring-tutorial
  buildpack: https://github.com/cloudfoundry/java-buildpack.git
  path: target/spring-tutorial-0.0.1-SNAPSHOT.war
  env:
    application_url: http://np-spring-tutorial.cfapps.io
  services:
   - np-spring-tutorial-db
  timeout: 180

通过点击和试用,我注意到实际需要的唯一设置是path: target/spring-tutorial-0.0.1-SNAPSHOT.war

现在应用程序正在运行,我可以看到页面。但是,在启动应用程序时,控制台上会出现以下错误:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/vcap/app/WEB-INF/lib/logback-classic-1.1.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/vcap/app/WEB-INF/lib/logback-classic-1.1.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]

【问题讨论】:

  • 它是 Spring Boot 应用程序吗?如果是,请提及引导版本号。
  • 是的,它是一个 Spring Boot 应用程序。版本是 1.3.2.RELEASE。 (更新了问题)

标签: spring spring-boot np-spring


【解决方案1】:

使用 - CF Java Build-packs

运行以下命令:

cf push webAppSpaceName -p spring-boot-sample-tomcat-jsp-1.3.3.RELEASE.war -b https://github.com/cloudfoundry/java-buildpack.git

由于您使用的是 Spring-Boot-1.3.2.RELEASE,您可能会遇到这个Issue

更新:

有关构建包的更多信息:

Buildpacks 为您的应用程序提供框架和运行时支持。 Buildpacks 通常会检查用户提供的工件以确定要下载哪些依赖项以及如何配置应用程序以与绑定的服务进行通信。

您不必明确提及要使用哪个 Buildpack,Cloud Foundry 会自动检测需要哪个 buildpack,并将其安装在需要运行应用程序的 Droplet 执行代理 (DEA) 上。 Reference.

但最好指定 CF 使用最新的构建包。

您可以在项目的manifest.yml 文件中指定构建包,然后使用仪表板进行部署:

buildpack: https://github.com/cloudfoundry/java-buildpack

但是,CF CLI 有更多的选项和功能。

【讨论】:

  • Just cf push np-spring-tutorial -p spring-tutorial-0.0.1-SNAPSHOT.war 似乎正在工作,正如我在问题中提到的那样。你的命令比这更好吗?那么Boot Dashboard 还不支持带有 JSP 的 WAR 吗?
  • 引导仪表板与 WAR 支持无关。它只是 CF CLI 的一个插件,使部署更容易。尽管它没有提供 CLI 提供的所有选项和功能。 -b https://github.com/cloudfoundry/java-buildpack.git 为您的应用程序定义了一个 Build-Pack,您也可以在项目的 manifest.yml 文件中定义它。您遇到的错误/问题与您的项目配置有关,您是否看过我提到的问题。更新了我的答案以获取有关构建包的更多信息。
  • PS:我在 PCF Dev 中测试并部署了这个 Spring-Boot-JSP 应用程序,它运行良好。
  • 你用过STS的Boot Dashboard吗?
  • 是的,我刚刚尝试了 Boot Dashboard 方式。它也工作正常。正如我所说,使用manifest.yml 文件,比如here
猜你喜欢
  • 1970-01-01
  • 2018-06-09
  • 2012-03-24
  • 2018-09-06
  • 2019-03-14
  • 1970-01-01
  • 1970-01-01
  • 2019-07-21
  • 1970-01-01
相关资源
最近更新 更多