当前位置: 首页 > 知识库问答 >
问题:

AWS CodePipeline将Spring Boot应用程序部署到Elastic BeansTalk

郜俊健
2023-03-14
    null
01_configure_application.sh] : Activity execution failed, because: Executing: /usr/bin/unzip -o -d /var/app/staging /opt/elasticbeanstalk/deploy/appsource/source_bundle
  FileMagic v0.7.1: compiled magic version [5.21] does not match with shared library magic version [5.37]
  Archive:  /opt/elasticbeanstalk/deploy/appsource/source_bundle
    inflating: /var/app/staging/microservices/my-service/target/my-service.jar  
  Unable to launch application as the source bundle does not contain either a file named application.jar or a Procfile.
  Unable to launch application as the source bundle does not contain either a file named application.jar or a Procfile. (ElasticBeanstalk::ExternalInvocationError)
caused by: Executing: /usr/bin/unzip -o -d /var/app/staging /opt/elasticbeanstalk/deploy/appsource/source_bundle
  FileMagic v0.7.1: compiled magic version [5.21] does not match with shared library magic version [5.37]
  Archive:  /opt/elasticbeanstalk/deploy/appsource/source_bundle
    inflating: /var/app/staging/microservices/my-service/target/my-service.jar  
  Unable to launch application as the source bundle does not contain either a file named application.jar or a Procfile.
  Unable to launch application as the source bundle does not contain either a file named application.jar or a Procfile. (Executor::NonZeroExitStatus)
build:
  commands:
      - mvn -P ci --settings settings.xml install -DskipTests
artifacts:
  files:
     - microservices/my-service/target/my-service.jar

共有1个答案

壤驷高旻
2023-03-14

虽然丹尼斯的回答是正确的,但我认为它不能清楚地解释这个问题。

当工件在artifacts指令下输出时,它必须是顶级的,或者在深度上最多只有一个目录。

例如,使用gradle的spring项目的默认情况是在执行bootjar任务后输出到 /build/libs/ .jar

version: 0.2

phases:
  install:
    runtime-versions:
      java: corretto8
  build:
    commands:
      # bootJar task outputs to build/libs/<name>.jar
      - ./gradlew bootJar
artifacts:
  files:
      - build/libs/<name>.jar

build阶段添加第二个命令,将该jar文件移到顶层,例如:

version: 0.2

phases:
  install:
    runtime-versions:
      java: corretto8
  build:
    commands:
      # bootJar task outputs to build/libs/<name>.jar
      - ./gradlew bootJar
      # move the jar (by wildcard, agnostic to its name) to top level app.jar
      - mv build/libs/*.jar app.jar
artifacts:
  files:
      # publish the now top level app.jar as the artifact
      - app.jar

最合适的解决方案是使用post_build指令,该指令用于清理/重组步骤,如下所示:

version: 0.2

phases:
  install:
    runtime-versions:
      java: corretto8
  build:
    commands:
      # bootJar task outputs to build/libs/<name>.jar
      - ./gradlew bootJar
  post_build:
    commands:
      # move the jar (by wildcard, agnostic to its name) to top level app.jar
      - mv build/libs/*.jar app.jar
artifacts:
  files:
      # publish the now top level app.jar as the artifact
      - app.jar

因此,当解压缩时,您将获得app.jar顶层,弹性豆茎是快乐的!注意app.jarbuild/libs是任意的,但是设置它们对您和您的项目都有意义。重要的是artifacts.files是顶级jar文件。弹性豆茎会照顾剩下的

 类似资料:
  • 完成干净的构建后,我将war文件复制到Tomcat的文件夹中。但是部署会发生两次,并且在上下文已经存在的情况下以异常结束。我错过了什么? 非常感谢您的帮助。

  • 问题内容: 我正在尝试在Heroku上使用Flask开发我的第一个“大型”应用程序,并尝试将此处的基本教程与以下说明结合:https : //devcenter.heroku.com/articles/python与以下说明:http:// flask.pocoo.org/docs/patterns/packages/#larger- applications。它在本地与“先行启动”一起工作,但是

  • 我想部署两个应用程序foo。war和条形图。war到同一个Tomcat实例。他们是否可以侦听不同端口上的连接,例如,foo侦听端口81,bar侦听端口82?如果是,我如何配置?我意识到应用程序没有必要监听不同的端口,但这正是我想要实现的。 此外,如果我将重命名为,使其在根上下文中运行,那么对该Tomcat实例的所有请求都将由foo应用程序处理,因此bar必须部署到单独的Tomcat实例,这是否正确

  • 我试图将Spring Boot应用程序部署到Heroku,但我无法做到这一点。我的应用程序会自动检测为"heroku-maven-plugin",但我想将其部署为Java应用程序。 我怎样才能做到这一点?

  • 尝试在Heroku云中部署Spring Boot应用程序,但编译java应用程序时出现错误,但在我的本地计算机中运行良好。

  • 我从昨天开始尝试在AWS Beanstalk上的Tomcat中部署Spring启动,但我总是出现此异常: 在我的本地开发环境中,我没有这个错误。在我的本地开发环境中,我在Tomcat 7上开发了“1.0.2.RELEASE”版本。 我创建了一场战争,我在AWS Beanstalk中的Tomcat 7实例上部署了它,但下面的错误总是出现。如何修复此错误?

  • Requirements 运行一个Spark Streaming应用程序,有下面一些步骤 有管理器的集群-这是任何Spark应用程序都需要的需求,详见部署指南 将应用程序打为jar包-你必须编译你的应用程序为jar包。如果你用spark-submit启动应用程序,你不需要将Spark和Spark Streaming打包进这个jar包。 如果你的应用程序用到了高级源(如kafka,flume),你需

  • 我已经构建了一个Springboot应用程序,其中包括AngLuar5。我有一个gradle构建脚本,它将angular文件加载到我的springboot项目中,这些文件位于springboot项目的resources/static下。当我启动我的应用程序时,angular的路由不再工作,我得到了 错误:无法匹配任何路由。URL段:“访问” 我的项目结构: 如果我打字 www.mysite.com