Run mvn spring-boot:run from parent module?

You can do it by adding following In parent pom:

  <build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
          <skip>true</skip>
        </configuration>
      </plugin>
    </plugins>
  </build>

And in your In my-app (Spring Boot module) pom:

 <plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
      <fork>true</fork>
      <skip>false</skip>
    </configuration>
    <executions>
      <execution>
        <goals>
          <goal>repackage</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

Now you can do execute in project root:

mvn -pl my-app -am spring-boot:run

Additional references:

  • spring-boot:run hot reload with multi module maven project · Issue #3436 · spring-projects/spring-boot · GitHub: in particular, this comment.

Tags:

Spring Boot