Description
László Stahorszki opened DATACMNS-1703 and commented
Let's say I have a project using Spring Data JPA, built by Maven. I have some repository interfaces in org.example.repositories
and a manual implementation as well, for let's say MongoDB.
To test my own implementation of the MongoDB repository, I create a test class in org.example.repositories
and all tests pass okay.
Now if I'd like to write some integration tests with actual H2 and MongoDB database, my repositories will simply not be found by the PathMatchingResourcePatternResolver
.
The reason is that the maven-surefire-plugin
patched the test org.example.repositories
into the module in my main source, the package has been overridden and the repositories will never be found by classpath scanning anymore. When scanning the org.example.repositories
package, the classloader only finds the test class for the MongoDB repository.
A solution to this problem could be brought from JPA. In the persistence.xml
there is a tag jar-files
which can be set to the output of maven-compile-plugin
. Scanning the directory instead of the classpath can work around the fact that patching a module into another overrides the packages instead of merging them
No further details from DATACMNS-1703