【问题标题】:buildspec.yml file for Spring Boot project用于 Spring Boot 项目的 buildspec.yml 文件
【发布时间】:2020-09-12 12:14:54
【问题描述】:

我有一个名为“BikeService”的 Spring Boot 项目。我正在使用 pom.xml 文件中的以下命令为这个项目生成一个 war 文件

<packaging>war</packaging>

现在我想将它部署在我使用

创建的 Elastic Beanstalk
Tomcat 8.5 with Java 8 running on 64bit Amazon Linux/3.3.6

上传代码后,部署成功,环境运行状况良好,但在运行环境 URL 时显示 HTTP 404 - Not Found

我正在使用以下 buildspec.yml 文件:

version: 0.2
phases:
  install:
    runtime-versions:
      java: corretto11
  pre_build:
    commands:
    - echo In the pre_build phase...
  build:
    commands:
    - echo Build started on `date`
    - mvn install
  post_build:
    commands:
    - echo Build completed on `date`
artifacts:
  files:
  - target/bike-service-0.0.1-SNAPSHOT.war
  - scripts/*

【问题讨论】:

  • 当您登录您的 EB 实例并从内部curl 您的应用程序时,它是否在您想要的端口上按预期工作?

标签: java spring amazon-web-services spring-boot amazon-elastic-beanstalk


【解决方案1】:

所以经过大量研究,问题解决了。

问题在于 buildspec.yml 文件。

我将发布正确的 buildspec.yml 文件,以防将来有人搜索它。

以下文件如果用于 带有战争包装的 Spring Boot 项目

version: 0.2
phases:
  install:
    runtime-versions:
      java: corretto8
  pre_build:
    commands:
    - echo In the pre_build phase...
  build:
    commands:
    - echo Build started on `date`
  post_build:
    commands:
    - echo Build completed on `date`
    - mvn package
    - mv target/bike-service-0.0.1-SNAPSHOT.war bike-service-0.0.1-SNAPSHOT.war
artifacts:
  files:
  - bike-service-0.0.1-SNAPSHOT.war
  - .ebextensions/**/*

【讨论】:

    猜你喜欢
    • 2022-07-11
    • 1970-01-01
    • 2021-04-06
    • 1970-01-01
    • 1970-01-01
    • 2017-03-08
    • 2017-07-30
    • 2015-04-30
    • 2023-04-10
    相关资源
    最近更新 更多