spring-projects / spring-projects/spring-data-commons
Repository lookup can fail in tests when JPMS is used [DATACMNS-1703]
@odrotbohm is already working on this.
Since Dec 30, 2020.
- Dominant language
- Java
- Stars
- 838
- Forks
- 730
- PR merge metrics
- No merged PRs in 30d
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.