Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify the Launcher in Spring Boot Gradle?

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!

like image 747
xing Avatar asked Mar 23 '16 01:03

xing


People also ask

How do I use Gradle spring boot?

When we apply the java plugin, the Spring Boot Gradle plugin takes multiple actions like: creating a bootJar task, which we can use to generate an executable jar file. creating a bootRun task, which we can use to run our application directly. disabling jar task.

What is bootRun in Gradle?

The Spring Boot gradle plugin provides the bootRun task that allows a developer to start the application in a “developer mode” without first building a JAR file and then starting this JAR file. Thus, it's a quick way to test the latest changes you made to the codebase.

Does spring boot use Maven or Gradle?

One example of this is the build system. A change to the build system affects those that contribute to the project but, if we get things right, it has no effect on users. This has led to a mixture of Maven- and Gradle-based builds. For example, Spring Framework has been built with Gradle since 3.2.


1 Answers

Add the layout property:

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

layout = ZIP Triggers SpringBoot to use the PropertiesLauncher

like image 194
pczeus Avatar answered Sep 24 '22 10:09

pczeus