When running the below code with Spring Boot v1.3.7 all works fine, but after bumping to version 1.4.0 maven goes crazy.
I was trying to do a simple integration test, not sure if I am doing something very wrong.
Basically running mvn clean package works on v 1.3.7 and stops working on v 1.4.0
The readme has details on how to reproduce and what breaks.
Simple project to reproduce https://github.com/pedroxs/multi-module-exception
Comment From: wilkinsona
This is due to the change in layout of executable jars in Spring Boot 1.4. Application classes are now packaging in BOOT-INF/classes.
Your client module depends on the repackaged, fat jar of your web module. Due to the new layout that means that the client module can no longer load the web module's classes. If you want to use your web module as a dependency, you should configure Boot's repackaging to apply a classifier to the fat jar. For example:
<build>
<plugins>
<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>
</plugins>
</build>
Doing so will allow other modules to depend on the original jar that does not embed the module's dependencies and has the classes at the root of the jar.
Comment From: snicoll
There is also an example in the doc - I've just polished that in cf07d19
Comment From: pedroxs
Thanks this solves the issue. Would you recommend a different approach for such kind of integration tests?
Comment From: alexanderche777
Thanks! It works for me.
Comment From: Huangjietian
Thanks, it's very useful for me.
Comment From: daunJung-dev
Thanks! I stuck at here while a day.. In my case, I applied QueryDSL to my project and it took this problem. (I don't know why it was) but I added the option you provided, and it works well.
I hope it help someone who struggled with QueryDSL Maven multi module package error 'package does not exist'!
Comment From: mvanassche
Another approach that worked for me was to add a classifier to the spring application module, such that the other submodule that depends on it can depend on the original, all that while keeping the repackaged jar without a classifier.
In the pom of the spring module:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>original</classifier>
</configuration>
</execution>
</executions>
</plugin>
...
</plugins>
</build>
In the pom of the submodule that depend on the spring module:
<dependency>
<groupId>...</groupId>
<artifactId>...-application</artifactId>
<version>${project.parent.version}</version>
<classifier>original</classifier>
</dependency>