Trouble Running Spring Boot Application from Jar with Included Dependencies for fast startup #40833
Labels
for: stackoverflow
A question that's better suited to stackoverflow.com
status: invalid
An issue that we don't feel is valid
I'm encountering an issue when trying to run a Spring Boot application from a jar file that includes its dependencies. Here's my setup:
I've created a new Spring Boot Gradle application and configured the jar task in my build.gradle file to include dependencies inside the generated jar file using the following snippet:
The jar file is generated successfully. However, when I try to run the generated jar using java -jar demo.jar, it starts but immediately stops. Interestingly, if I use bootJar, the application runs perfectly.
My goal is to improve startup time, and I've explored solutions like GraalVM. However, compatibility issues arise with dependencies such as Log4j, Flyway, and Liquibase, especially considering that my project has multiple modules with their own dependencies.
When I tried the same approach mentioned above with another project, I encountered different issues:
I attempted to utilize the Shadow library (com.github.johnrengelman.shadow), but encountered numerous errors. Despite this, I managed to execute the generated JAR, albeit with different errors.
You can generate the Spring Boot project using the following link: Spring Initializr
I'm seeking guidance on the correct approach to achieve faster application startup time while including dependencies in the jar. Any insights or suggestions would be greatly appreciated. Thank you.
The text was updated successfully, but these errors were encountered: