Generally while resolving a transitive dependency (or on conflict, which is not the case in this case) Maven will choose the nearest dependency. If you want to specify exact version declare it as If, for some strange reason, you want to force hibernate-jpa-2.1-api to be used instead, you need to explicitly exclude javax.persistence-api as a transitive dependency like so: ġ.0.2.Final - This declaration says : allow any version, but prefer 1.0.2.FINAL. Note that Maven does not have a way of knowing hibernate-jpa-2.1-api and javax.persistence-api are supposed to be interchangeable. This is why you're getting the 'Used undeclared dependencies found' warning.įor the very same reason, :hibernate-jpa-2.1-api:1.0.2.Final is not used. It's really quite simple: org.hibernate:hibernate-core:5.4.15.Final depends on javax.persistence.* classes from javax.persistence:javax.persistence-api:2.2 (that's the dependency declared in its own POM) and so, by including hibernate-core, you get an additional, transitive dependency javax.persistence-api pulled in. If I try to switch to the javax.persistence:javax.persistence-api:jar:2.2 instead of the hibernate one I get a lot of errors from 'mvn package' that look like this: Found duplicate (but equal) classes in : So why won't Maven accept that this is the jar to use and insists it wants the javax.persistence-api instead? I checked the jar from hibernate-jpa-2.1-api and it does contain the javax.persistence.* classes. javax.persistence:javax.persistence-api:jar:2.2:compile I can compile ok using "mvn compile" but when I try to "mvn package" I get the following error: Used undeclared dependencies found: I have the following dependencies in pom.xml: I have some code that uses: import javax.persistence.*
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |