我正在尝试将我的 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/