Issue
My spring boot war is simply too large and I want to make some optimalisation. SPring boot has the option to run war with java -jar
, that is why lib-provided
(with all provided
dependecies) is still inside the war even though the dependecies are not needed there (I will never run it as standalone). Can I somehow disable this clever functionality, so that I can save some space?
UPDATE: I am using Maven and spring boot maven plugin.
Solution
By Default Spring Boot Maven plugin will repackage your application into a executable WAR/JAR.
The original (i.e. non executable) artifact is renamed to .original by default but it is also possible to keep the original artifact using a custom classifier. refer the Spring Documentation
For Example:
If your app is named as MyApplication and you are trying to package it into a WAR, The following steps will happen:
- The application will first be built as usual and you would get
MyApplication-0.0.1-SNAPSHOT.war
- Then spring boot maven plugin will repackage it into an executable WAR (with the same name) and it will rename the original packaged application to
MyApplication-0.0.1-SNAPSHOT.war.original
. - You are now having two packaged applications:
MyApplication-0.0.1-SNAPSHOT.war
(Spring boot executable)MyApplication-0.0.1-SNAPSHOT.war.original
(Non-Executable application)
You can either remove the Spring Boot Maven Plugin all together or use the Non-Executable version.
Answered By - Manish Kothari
Answer Checked By - Marilyn (JavaFixing Volunteer)