Skip to content
Advertisement

NoClassDefFoundError for Gradle fat jar with tests Spring Boot

I need to create fat jar in Gradle project with tests where Main method is under src/test. Now I have Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/cli/CommandLineParser when I run fat jar created by ‘gradle bootJar’.

My Gradle:

JavaScript

My spring.xml:

JavaScript

Exception:

JavaScript

Previously following ‘gradle shadowJar’ code worked well until I added AspectJ to the project

JavaScript

And error appeared on running ‘gradle shadowJar’

JavaScript

Somewhere I found that shadowJar doesn’t work properly with Spring

How can I create fat jar for Spring project with main class under src/test?

Advertisement

Answer

This Gradle shadowJar works for me

JavaScript
Advertisement