Maven Multi-module dependency package not found

In the rest-client-microservice Spring Boot project add this configuration to the spring-boot-maven-plugin.

<configuration>
 <classifier>exe</classifier>
</configuration>

so it will look like that.

           <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <classifier>exe</classifier>
                </configuration>
            </plugin>

Source: https://spring.io/guides/gs/multi-module/

To tell Maven to not build an executable jar for the Library project, you must remove the following block from the pom.xml created by the Spring Initializr:

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

I figured it out. The rest-client-microservice is a Spring Boot project and uses the following plugin:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <executions>
        <execution>
            <goals>
                <goal>repackage</goal>
            </goals>
        </execution>
    </executions>
</plugin>

The jar is repackaged and all the packages and classes are put in the BOOT-INF folder. That's the reason why Maven is unable to find them. You can fix this by defining the plugin like this:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <executions>
        <execution>
            <goals>
                <goal>repackage</goal>
            </goals>
            <configuration>
                <classifier>exec</classifier>
            </configuration>
        </execution>
    </executions>
</plugin>

With this configuration, the Spring Boot Maven Plugin will create 2 JARs: the main one will be the same as a usual Maven project, while the second one will have the classifier appended and be the executable JAR.


I am using Spring Boot 2.2.7, for this version and later, removing the following from the parent pom.xml:

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

solved the problem