任务':bootRun'执行失败:Java进程非零退出值1求助
bootRun Non-Zero Exit Code 1 Failure Hey there, I know how frustrating it is when you’ve tried all the usual fixes—reinstalling Java, Gradle, digging through similar issues—and still hit that non-zero exit code 1 error with bootRun. Let’s break down targeted steps to get to the root of this:
First, grab the full error details
Exit code 1 is just a generic "something went wrong" signal—we need the actual stack trace or error messages that show up right before this line. Run the command with verbose logging to unlock more context:gradlew bootRun --infoOr for hyper-detailed output:
gradlew bootRun --debugIf you already have a full stack trace, sharing that would make pinpointing the issue way easier.
Check for common startup blockers
- Port conflicts: Spring Boot defaults to port 8080—on Windows, run this to see if another process is hogging it:
If it’s occupied, kill the process or tweak the port in yournetstat -ano | findstr :8080application.properties/application.yml. - Configuration file typos: Missing colons in YAML, invalid property names, or misspelled values are super common culprits. Double-check every line, especially if you recently edited your configs.
- Java version mismatch: You’re using JDK 9.0.4—make sure it lines up with your Spring Boot version’s requirements:
- Spring Boot 2.x supports Java 8-17
- Spring Boot 3.x requires Java 17+
If your project is on Spring Boot 3.x, JDK 9 will definitely cause startup failures.
- Port conflicts: Spring Boot defaults to port 8080—on Windows, run this to see if another process is hogging it:
Wipe caches and rebuild from scratch
Cached files often cause weird, hard-to-track issues. Try these steps:- Delete the
buildfolder in your project root - Delete the
.gradlefolder in your project root - Clear Gradle’s global cache (Windows path:
C:\Users\YourUsername\.gradle\caches) - Run a clean, cache-free build:
gradlew clean build --no-build-cache
Then give
bootRunanother shot.- Delete the
Test running the built JAR directly
Sometimes thebootRuntask hides more detailed errors. Build the JAR first:gradlew buildThen run it with Java directly:
java -jar build/libs/your-application-name.jarThis often surfaces clearer messages about missing dependencies, classpath issues, or runtime failures.
Verify Gradle and Spring Boot plugin compatibility
Make sure your Gradle version aligns with the Spring Boot plugin version in yourbuild.gradle:- Spring Boot 2.7.x works best with Gradle 7.x
- Spring Boot 3.x requires Gradle 8.x
A mismatch here can trigger silent startup failures that only show up as exit code 1.
If you can share more details—like the full stack trace, your build.gradle content, or your Spring Boot version—I can help narrow this down even further!
内容的提问来源于stack exchange,提问作者Antonio De la Torre

