etig etig - 3 days ago 5
Java Question

Specify main class Spring-Boot command line

I use maven plugin to set the main class like this :

<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.myapp.main.MainClass</mainClass>
</configuration>
</plugin>


But sometimes I want run my app with another main class. What is the command line arguments to do this?

java -jar myapp-1.0.jar ...


Thx

Answer

There's a launcher for that in Spring Boot already. You need to build the jar with that as the Main-Class (by setting the layout in the build config).

Comments