Heroku上的Java Web应用程序:无法访问jarfile

我正在尝试将我的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运行bash –app myapp with ls -a不显示目标目录.

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

最佳答案
而不是mvn install做mvn包知道差异检查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 Web应用程序:无法访问jarfile - 代码日志