You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Heroku部署Spring Boot Gradle应用后启动崩溃,API请求返回503 Service Unavailable求助

Fixing "no main manifest attribute" & H10 Crash for Spring Boot + Gradle on Heroku

Let's break down your issue and fix it step by step:

Root Cause

The error no main manifest attribute, in build/libs/LawCase-0.0.1-SNAPSHOT-plain.jar tells us exactly what's wrong: you're trying to run the plain JAR generated by Gradle's standard jar task. This JAR doesn't include Spring Boot's bootstrap logic or metadata pointing to your main application class. Spring Boot apps require the executable JAR created by the bootJar task (the one without the -plain suffix).

Step 1: Fix Your Procfile

Update your Procfile to target the correct executable JAR (remove the -plain suffix):

web: java -jar build/libs/LawCase-0.0.1-SNAPSHOT.jar

Before redeploying, test the JAR on your local machine to confirm it works as expected:

java -jar build/libs/LawCase-0.0.1-SNAPSHOT.jar

If it starts up successfully and you can access your API locally, you're ready to redeploy.

Step 3: Redeploy to Heroku

Commit your Procfile change and push to Heroku:

git add Procfile
git commit -m "Fix Procfile to use Spring Boot executable JAR"
git push heroku main

Step 4: Validate the Deployment

After deployment, check the Heroku logs to confirm no startup errors:

heroku logs --tail

You should see Spring Boot's familiar startup logs instead of the manifest error. Once the app shows a "running" state, test your API endpoint https://lawcase.herokuapp.com/getprofiles again.

Additional Checks (If Issues Persist)

  • Confirm your build.gradle has the Spring Boot plugin correctly applied (this ensures the bootJar task is enabled):
    plugins {
        id 'org.springframework.boot' version 'your-spring-boot-version'
        id 'io.spring.dependency-management' version 'your-dependency-management-version'
        id 'java'
    }
    
  • Double-check that your main application class has the @SpringBootApplication annotation and a valid main method:
    @SpringBootApplication
    public class LawCaseApplication {
        public static void main(String[] args) {
            SpringApplication.run(LawCaseApplication.class, args);
        }
    }
    

内容的提问来源于stack exchange,提问作者Ahmad

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.01 01:42:28