简体   繁体   中英

Why is deploying gradle java app to heroku failing?

I am trying to deploy a gradle java app to heroku from my local machine. My project contains the following files

在此处输入图片说明

I have defined the following tasks in my build.gradle

task stage {
  dependsOn build
}

task wrapper(type: Wrapper) {
    gradleVersion = '2.12'
}

The content of ProcFile is as follows:

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

While executing git commit heroku master I get the following error

在此处输入图片说明

while executing git ls-files gradle the following files are listed 在此处输入图片说明

Could you please suggest why I am getting the error while deploying the app to heroku server?

If you are using gradlew, then you must also add your gradle/wrapper/gradle-wrapper.jar and gradle/wrapper/gradle-wrapper.properties to your Git repository. If you do not add these files, you will receive an error such as:

 -----> executing ./gradlew stage Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain 

And to solve it:

You can add the wrapper files by running these commands:

 git add gradle/wrapper git commit -m "Gradle Wrapper" 

From Deploying Gradle apps on Heroku .

You don't need this

task stage{
    dependsOn build}
    task wrapper(type:Wrapper){
    gradleVersion = '5.6.1'
}

Instead try using this:

task stage(dependsOn: ['clean', 'installDist'])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM