Maven test classloader doesn't include target/classes folder

Viewed 167

I have a Maven project built on JDK 11, making full use of the Java Module System.

My problem is that I'd like to use Spring Data JPA repositories in my tests, but the Jpa Bean factory can't find my repository interfaces.

After some digging, I found that the reason is the classloader that Spring is trying to use to find the repository interfaces doesn't include the folder where the compiled main class files are saved, target/classes. Despite the fact that the Maven surefire documentation says that the directory should be included as the 2nd highest priority.

To better describe the issue, I created a demo GitHub repo, where I demonstrate my problem.

Without the module-info.java everything seems to work fine.

0 Answers
Related