Heroku上的Spring Boot Gradle应用程序:无法访问jarfile

西蒙

我有一个spring boot gradle应用程序,可以通过以下操作在PC上成功运行:

heroku local

我也可以在heroku上成功部署它:

git push heroku master

这是我的结果:

Counting objects: 17, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (9/9), 596 bytes | 0 bytes/s, done.
Total 9 (delta 3), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Fetching set buildpack https://github.com/heroku/heroku-buildpack-gradle... done

remote: -----> Gradle app detected
remote: -----> Installing OpenJDK 1.8... done
remote: -----> Building Gradle app...
remote:        WARNING: The Gradle buildpack is currently in Beta.
remote: -----> executing ./gradlew build
remote:        :compileJavaNote: Some input files use unchecked or unsafe operations.
remote:        Note: Recompile with -Xlint:unchecked for details.
remote:
remote:        :processResources
remote:        :classes
remote:        :jar
remote:        :bootRepackage
remote:        :assemble
remote:        :compileTestJava UP-TO-DATE
remote:        :processTestResources UP-TO-DATE
remote:        :testClasses UP-TO-DATE
remote:        :test UP-TO-DATE
remote:        :check UP-TO-DATE
remote:        :build
remote:
remote:        BUILD SUCCESSFUL
remote:
remote:        Total time: 11.935 secs
remote:
remote: -----> Discovering process types
remote:        Procfile declares types -> web
remote:
remote: -----> Compressing... done, 72.3MB
remote: -----> Launching... done, v9
remote:        https://myapp.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/myapp.git
   6326429..291326d  master -> master

但是,当我尝试在heroku上访问它时,它崩溃了。heroku日志说:

2015-12-11T17:05:46.096985+00:00 heroku[api]: Deploy 291326d by [email protected]
2015-12-11T17:05:46.097021+00:00 heroku[api]: Release v9 created by [email protected]
2015-12-11T17:05:46.378258+00:00 heroku[slug-compiler]: Slug compilation started
2015-12-11T17:05:46.378269+00:00 heroku[slug-compiler]: Slug compilation finished
2015-12-11T17:05:46.755655+00:00 heroku[web.1]: State changed from crashed to starting
2015-12-11T17:05:53.121398+00:00 heroku[web.1]: Starting process with command `java -Dserver.port=5000 -jar  build/libs/myapp.jar`
2015-12-11T17:05:54.260741+00:00 app[web.1]: Error: Unable to access jarfile build/libs/myapp.jar
2015-12-11T17:05:54.784064+00:00 heroku[web.1]: State changed from starting to crashed
2015-12-11T17:05:54.773714+00:00 heroku[web.1]: Process exited with status 1
2015-12-11T17:05:54.788248+00:00 heroku[web.1]: State changed from crashed to starting

为什么呢Unable to access jarfile build/libs/myapp.jar

当我导航到本地PC上的该文件夹时,jarfile就在其中。

我没有解决该问题的想法。

西蒙

我最终在这里找到了一个非常有用的线程:在Heroku上运行使用gradle构建的Spring应用程序

这帮助了我解决我的问题-该线程似乎比Heroku的官方指南更详细。

您必须将以下代码添加到build.gradle文件中:

task stage(type: Copy, dependsOn: [clean, build]) {
    from jar.archivePath
    into project.rootDir
    rename {
        'app.jar'
    }
}
stage.mustRunAfter(clean)

clean << {
    project.file('app.jar').delete()
}

然后,将您的Procfile指向app.jar:

web: java $JAVA_OPTS -jar app.jar

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Spring Boot:无法访问localhost上的REST Controller(404)

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

Spring Boot应用程序中的Rest API无法在本地网络上访问

无法将Spring Boot应用程序部署到heroku

无法通过Spring Boot应用程序访问角度页面

Vaadin Spring应用程序无法访问的图像

带有Spring Boot REST应用程序的OAuth2-无法使用令牌访问资源

在tomcat中部署后无法访问Spring Boot应用程序

Gradle Maven-publish无法构建独立的Spring-boot应用程序

从Spring Boot应用程序访问SessionFactory

无法访问EBS上托管的Spring Boot应用程序

如何在Heroku上为Spring Boot应用强制HTTPS?

Docker-Spring Boot应用程序-无法访问本地主机上的MySql服务器

使用Spring Boot开发人员工具时IntelliJ无法启动Spring Boot / Gradle应用程序

Swagger 2 UI无法访问,Spring Boot应用程序部署在外部tomcat上

在Spring Boot应用程序中无法从浏览器访问http:inbound-gateway映射

无法从浏览器访问远程Spring Boot应用程序

无法访问VPS上的Spring Boot 2

无法访问端口80上的应用程序

在heroku上运行spring boot应用程序时,“无法从JAR文件读取TLD”

用于Heroku上的Spring Boot应用程序的MongoDB连接

无法使用 bitbucket 管道在 Heroku 中部署 spring-boot 应用程序

无法访问我的 Spring Boot 应用程序页面

Spring Boot 应用程序无法启动?

无法访问请求映射 spring boot

无法访问部署在 kubernetes 集群上的应用程序

Kubernetes 上的 nginx 无法访问角度应用程序

Spring 应用程序无法访问控制器

为什么我的简单 Spring Boot 应用程序无法在 Heroku 上部署?