Spring Boot Gradle app on Heroku: Unable to access jarfile

后端 未结 3 1159
無奈伤痛
無奈伤痛 2021-01-03 09:49

I have a spring boot gradle app which I could run successfully on my PC by doing:

heroku local

It can also deploy on heroku successfully wh

3条回答
  •  遥遥无期
    2021-01-03 10:04

    You don't need to modify your stage task for that.

    In your gradle.build file, make sure to give a name to your built artifact like this.

    jar {
        baseName = 'app'
        version = '0.0.1'
    }
    

    With that been done, and the following in Procfile, it should just run fine.

    web: java -Dserver.port=$PORT $JAVA_OPTS -jar build/libs/app-0.0.1.jar
    

    I found that if name is not explicitly defined, heroku seems to name the artifact something like build-{buildNumber}.jar and no wonder it will never find the app.jar.

    Also, if not set already, the build pack needs to be set.

    heroku config:set GRADLE_TASK="build"
    

提交回复
热议问题