In case one builds one Springboot app which requires jar to be provided on runtime, here's the recipe:
- Change "Main-Class" attribute in jar manifest, here's one example of configuration in gradle:
bootJar { manifest { attributes( "Main-Class": "org.springframework.boot.loader.PropertiesLauncher" } } }
- To run the app, add loader.path parameter pointing to the folder location of the jar
java -Dloader.path=lib/ -jar application.jar
Tips:
- Default "Main-Class" in Springboot jar
"Main-Class": "org.springframework.boot.loader.PropertiesLauncher
- "Start-Class" attribute in the manifest points to the main class, the class annotated with SpringBootApplication
No comments:
Post a Comment