Spring Boot maven plugin example 2018-11-07 21:52

spring-boot-maven-plugin can help you build runnable Spring Boot jar. Add following config in your pom file and execute clean install you will get a runnable jar file.

                        <mainClass>com.henryxi.mavenplugin.TestController</mainClass> <!-- your main method -->

If you do not add "executions" config in your pom, you need run mvn package spring-boot:repackage to generate runnable jar file.

The TestController is here

public class TestController {
    @RequestMapping(path = "/get", method = RequestMethod.GET)
    public String get() {
        return "This is Get response";

    public static void main(String[] args) throws Exception {
        SpringApplication.run(TestController.class, args);

After executing mvn clean install you will get two files in your target directory. The one is runnable jar file and another is original jar(without dependency libs). Then you can start this Spring Boot application by java -jar YOUR_RUNNABLE_JAR_PATH.