Maven - how to add all required dependencies for hibernate?
If you want to use JPA with Hibernate, you only need a single Maven dependency. Refer to the download page:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.4.10.Final</version>
</dependency>
This dependency will pull all the required other artifacts as transitive dependencies (like the JPA API, Hibernate Core and a lot of others).
This is the power of Maven. You don't need to add anything manually to the classpath or figure out yourself which jars you should add. One Maven dependency will declare as transitive dependencies everything that it needs.
When specifying a dependency with pom.xml it won't be included into your dependencies library as you are expecting (a jar file). Here is a list of basic hibernate artifact ids that I use to include:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate.common</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>${hibernate.version}</version>
<classifier>tests</classifier>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>1.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernate.version}</version>
</dependency>
Replace the ${hibernate.version} with desired version or define a property with this identifier.
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.0.2.Final</version>
</dependency>