I upgraded my library recently from gradle 5.X to 7.3.1 and upgraded Spring-Boot from 2.4.X to 2.6.X but I'm facing an issues. I was using gradle build to create a jar and execute this jar on my server and that was working fine with Spring-Boot 2.4.X but now with 2.6.X I got some issues:
no main manifest attribute
So I added to my build.gradle
jar {
manifest {
attributes "Main-Class": "my.package.MainClass"
}
from {
configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) }
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
}
And now i'm getting the error
Could not find or load main class my.package.MainClass
If I'm switching back to 2.4.X it's working fine. My jar from :
- spring-boot 2.4.X -> 90Mo
- spring-boot 2.6.X -> 500 Ko
So I tried to create a fat jar with shadowJar and got this error
ERROR org.springframework.boot.SpringApplication - Application run failed Dec 21 10:04:09 vps-11602ed1 project[12706]: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
If someone got an answer about how to make it works with Spring-boot 2.6.X.
Thanks in advance
CodePudding user response:
I found the problem. When I'm upgrading from springboot 2.4.X to 2.6.X, now gradle build is generating a new jar "plain" with my casual jar. And I renamed my jar to the same name. So instead of using the biggest jar, I was using the smallest. Just added that to my gradle.build:
jar {
enabled = false
}
So now, it's not creating the "plain" jar and everything is working fine