Maven reactor: pom using Spring boot starter pom

1.7k views Asked by At

I have a project with multiple modules. Some of these use spring boot, others are plain jars without any spring dependency. So I have a parent pom.xml setup with each module. Trouble is with the spring boot projects.

I've setup spring boot dependencies as scope=import as listed here in each spring boot project. Is this correct? Or should I move it into my parent POM?

Issues I'm running into 1. When I run mvn package from the top folder, it isn't repackaging the spring boot jars. 2. My spring boot projects were listing other spring boot dependencies. with spring boot starter as parent, they didn't need a version tag. Now they do. I've defined that as a property in my parent pom and added the version tag but want to know if that's better.

Thanks for reading.

Update response to comment #1: I have the spring-boot-maven-plugin in my parent POM as follows

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>1.1.9.RELEASE</version>
        </plugin>
    </plugins>
    <pluginManagement>
 ....
 </build>

I've also tried running mvn spring-boot:repackage manually inside my spring boot project- but that errors out with :repackage failed: Source must refer to an existing file -> [Help 1]

1

There are 1 answers

1
Ori Dar On BEST ANSWER

If you don't inherit from spring boot parent, you have to declare spring-boot-maven-plugin in the plugins section in your pom in order for repackage to take place.

You'll have to add the following to the plugin:

 <executions>
     <execution>
         <goals>
             <goal>repackage</goal>
         </goals>
     </execution>
  </executions>

You should put the plugin under pluginManagement in the parent pom, and add

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven‌​-plugin</artifactId>
</plugin> 

under each build section for each module which relies on spring boot.