spring gradle don't build boot jar

  1. Ensure the 'plugins' block in your build.gradle file includes the 'org.springframework.boot' and 'io.spring.dependency-management' plugins:
plugins {
    id 'org.springframework.boot' version '2.5.5'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    // other plugins...
  1. Apply the 'java' plugin to enable Java compilation:
apply plugin: 'java'
  1. Define the Spring Boot dependencies in the 'dependencies' block:
dependencies {
    implementation 'org.springframework.boot:spring-boot-starter'
    // other dependencies...
  1. Make sure the 'main' class is specified in the 'springBoot' block:
springBoot {
    mainClassName = 'com.example.YourApplicationClass'

Replace 'com.example.YourApplicationClass' with the actual package and class name of your main application class.

  1. Ensure that the 'sourceCompatibility' and 'targetCompatibility' are set to the Java version you are using:
sourceCompatibility = '11'
targetCompatibility = '11'

Replace '11' with your Java version.

  1. Verify that the 'repositories' block includes the necessary repositories:
repositories {
    // other repositories...
  1. Run the 'bootJar' task to build the Spring Boot JAR:
./gradlew bootJar

Replace './gradlew' with 'gradlew.bat' if you are using Windows.

  1. Locate the generated JAR file in the 'build/libs' directory:
ls build/libs/

Replace 'ls' with 'dir' if you are using Windows. The JAR file should have a name like 'your-application-name-1.0.0-SNAPSHOT.jar', where 'your-application-name' is the name of your application.

  1. Verify that the JAR file can be executed:
java -jar build/libs/your-application-name-1.0.0-SNAPSHOT.jar

Replace 'your-application-name-1.0.0-SNAPSHOT.jar' with the actual name of your JAR file.

  1. If any issues arise, review the build output and resolve any reported errors or missing dependencies.