Heroku 上的 Java 网络应用程序 : Unable to access jarfile

标签 java maven heroku github spring-boot

我正在尝试将我的 Java Spring Boot Web 应用程序部署到 Heroku。

要在本地启动它,我运行:

mvn 安装

然后

java $JAVA_OPTS -jar target/*.war

因此,对于 Heroku,我创建了 Procfile: web: java $JAVA_OPTS -jar target/*.war

我使用 Heroku Github 集成并将应用程序从 Github 部署到 Heroku。所以我就把它推到那里。

但是应用程序没有启动。

heroku logs --app myapp 给我:

2015-09-09T21:53:25.581128+00:00 heroku[web.1]: Starting process with command `java $JAVA_OPTS -jar target/*.war`
2015-09-09T21:53:27.110820+00:00 app[web.1]: Error: Unable to access jarfile target/*.war`

heroku run bash --app myapp with ls -a 不显示 target 目录。

我认为 Heroku 不会构建该应用程序。 但我做错了什么?在此先感谢您的建议!

最佳答案

代替 mvn install 执行 mvn package 来了解差异检查 http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html

Deploying a WAR file with the Heroku Maven plugin allows you to integrate the deployment process with your existing Maven process. The Heroku plugin uses the artifacts generate by your mvn package phase, and builds them into a Slug file that is uploaded to the Heroku servers.

In this way, the Heroku Maven plugin avoids the overhead of recompiling your project remotely. This is often the preferred approach when deploying from a CI server, which may already have built your WAR file and tested it.

来源:https://devcenter.heroku.com/articles/war-deployment#deployment-with-the-heroku-maven-plugin

关于部署Spring Boot,需要采取以下步骤:

  • 配置端口

    web: java -Dserver.port=$PORT -jar target/demo-0.0.1-SNAPSHOT.jar

  • 指定JDK,默认1.8(Maven中指定1.8则无需更改)

检查 http://docs.spring.io/spring-boot/docs/current/reference/html/cloud-deployment-heroku.html

要执行 Procfile 使用 heroku local

关于Heroku 上的 Java 网络应用程序 : Unable to access jarfile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32490217/

相关文章:

python - Whitenoise、Mezzanine、Django -ImportError : cannot import name ManifestStaticFilesStorage

java - Android 版本名称/版本代码( list )的最大长度

java - 在java中从xml设置数字

java - Gradle with IntelliJ 不加载 PostgreSQL JDBC 作为依赖项

java - 确定每个 Maven 依赖项(jar)被调用的位置并删除未使用的

java - heroku 应用程序中的端口和 url 错误

java - 使用 Tomcat 部署动态 Web 项目

java - 为什么我的 DataInputStream 只读取 114 字节?

java - 我正在尝试使用 wro4j Maven 在构建时压缩 js 和 css 文件

django - Heroku Collectstatic 超时与 Django 应用程序