Skip to content

Spring Boot Gradle Plugin

DodaTech 1 min read

In this tutorial, you'll learn about Fix Spring Boot Gradle Plugin BootJar Not Runnable. We cover key concepts, practical examples, and best practices.

The Problem

The bootJar produces a non-executable JAR or classpath issues arise.

Quick Fix

Apply Spring Boot plugin

Wrong:

plugins {
    id 'java'
}
// No Boot plugin

Output:

BootJar task not available

Right:

plugins {
    id 'java'
    id 'org.springframework.boot' version '3.2.0'
}

Output:

BootJar task available

Apply io.spring.dependency-management

Wrong:

// No dependency management

Output:

Version conflicts

Right:

plugins {
    id 'io.spring.dependency-management' version '1.1.4'
}

Output:

Dependencies managed

Configure bootJar

Wrong:

bootJar {
    // No configuration
}

Output:

Default config may be wrong

Right:

bootJar {
    mainClass = 'com.example.MyApplication'
    archiveFileName = 'myapp.jar'
}

Output:

BootJar configured

Prevention

  • Apply Spring Boot Gradle plugin
  • Apply dependency management plugin
  • Configure bootJar with main class

Common Mistakes with boot gradle plugin

  1. Placing the wildcard pattern first in case expressions, making all subsequent patterns unreachable
  2. Using head and tail instead of pattern matching, causing runtime errors on empty lists
  3. Forgetting that lazy evaluation defers computation until the value is forced, causing space leaks with unevaluated thunks

These mistakes appear frequently in real-world SPRING code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### How is bootJar different from jar?

bootJar creates a fat JAR with embedded dependencies. The standard jar task creates a thin JAR.

This quick fix is part of the DodaTech Spring & JVM ecosystem series. Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro