6

There three launcher in Spring Boot: JarLauncher/PropertiesLauncher/WarLauncher. For executable jar, JarLauncher will be used by default. Now I want to use PropertiesLauncher instead so that I could use external classpath. How could I specify that is spring boot gradle plugin?

Accoring to D3.1 of this doc D.3.1 Launcher manifest, I can specify the main class in MANIFEST.MF like this:

Main-Class: org.springframework.boot.loader.JarLauncher Start-Class: com.mycompany.project.MyApplication 

However, in Spring Boot Gradle, the following code snippet actually specifies the Start-Class, not the Main-Class:

springBoot { mainClass = "com.sybercare.HealthServiceApplication" } 

Do I need to create the MANIFIEST.MF manually or there is a better way to do this?

Thanks!

3 Answers 3

7

Add the layout property:

springBoot{ mainClass = "com.sybercare.HealthServiceApplication" layout = "ZIP" } 

layout = ZIP Triggers SpringBoot to use the PropertiesLauncher

Sign up to request clarification or add additional context in comments.

1 Comment

thank you so much @pczeus. I was looking for this solution but could not find it easily. where did you find docs for that?
1

The layout property defaults to a guess based on the archive type (jar or war). For the PropertiesLauncher the layout is ZIP (even though the output might be a jar file).

https://docs.spring.io/autorepo/docs/spring-boot/1.2.0.M2/maven-plugin/usage.html

Comments

1

The other answers are outdated now. The current answer seems to be:

tasks.getByName<BootJar>("bootJar") { manifest { attributes("Main-Class" to "org.springframework.boot.loader.PropertiesLauncher") } } 

as per https://docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/htmlsingle/#packaging-executable.configuring.properties-launcher

1 Comment

I had to use org.springframework.boot.loader.launch.PropertiesLauncher.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.