So I have a spring application divided into several modules, each in a separate project. Each module has its own JPA entities and I'm using Spring ORM for configuration:
<beans ...>
<context:component-scan
base-package="org.myapp.module1.persistence" />
<context:component-scan
base-package="org.myapp.module2.persistence" />
...
<context:annotation-config />
<tx:annotation-driven />
...
</beans>
And the persistence.xml file looks like this:
<persistence ...>
<persistence-unit name="myunit" />
</persistence>
My problem is that when Spring context initializes it will only look for the @Entity classes on the same path of the persistence.xml file, and will ignore the other projects classpaths.
I tried to have multiple persistence.xml, each one in the same path as the @Entity classes, but in this case once Spring finds the first persistence.xml it stops loading and will not find any @Entity classes on other paths.
How can I make Spring look at everything?