I have three modules in my Maven project (this is slightly simplified):
- model contains JPA annotated entity classes
- persistence instantiates an EntityManager and calls methods on it
- application creates instances of the classes in model, sets some values and passes them to persistence
model and persistence obviously depend on javax.persistence
, but application shouldn't, I think.
The javax.persistence
dependency is moved to a top-level POM's dependencyManagement
section because it occurs in a number of submodules where I only reference that entry.
What's surprising to me is that I have to reference the dependency in application
when I set its scope to provided
, whereas I don't have to when its scope is compile
.
With a scope of provided
, if I don't list it in the dependencies
for application, the build fails with an error message from javac:
com.sun.tools.javac.code.Symbol$CompletionFailure: class file for javax.persistence.InheritanceType not found
What's going on?