Reputation: 11499
I have project that uses Hibernate: hibernate-core-3.6.7.Final.jar
In its POM I found:
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
</dependency>
Should I include all dependencies in my application or does Maven do that itself?
Upvotes: 1
Views: 2020
Reputation: 90467
If you specify a <dependency>
in your pom.xml
, not only its jars will be downloaded to your local repository , but a POM file will also be downloaded . Maven will then look for the information in such POM file to find out what other libraries it needs to retrieve. This is what the idea of Maven 's transitive dependencies feature
So , it relies on the accuracy and completeness of such POM files stored on the public repository.If the dependencies in such POM file are not updated or empty , you have to supply the dependencies explicitly in your own pom.xml
if necessary.
For hibernate , hibernate-core
already depends on hibernate-jpa-2.0-api
which means that hibernate-jpa-2.0-api
will be download if you include hibernate-core
in the pom.xml
. So , hibernate-jpa-2.0-api
is redundancy and can be removed.
If you want to use JPA interface with the hibernate , you can just include hibernate-entitymanager
in the <dependency>
as it depends on hibernate-core
and hence will download it too.
To conclude, I suggest you simply include hibernate-entitymanager
in the <dependency>
:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.6.7.Final</version>
</dependency>
Upvotes: 3
Reputation: 10270
All the dependencies that you need, you will have to add manually in your pom.xml file. If configured properly, maven will automatically download all the libraries corresponding to the dependencies you added there and they will be ready to use in your applicaiton.
Upvotes: 1
Reputation: 4929
Maven is used for that. You should install the m2 plugin for Eclipse (if you're coding on eclipse) and then right click on your project -> Update Project Dependencies.
But Maven is used for that, it means that when you add a dependency in your project, Maven will download the libs, and add them in the right place in your project.
Upvotes: 2