Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Maven adds Hibernate Jars in dependency when i use Spring-Data

Whenever i add dependency like below, maven also adds hibernate-entitymanager-4.3.10.jar, hibernate-core-4.3.10.jar...

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.rajkishan</groupId>
<artifactId>Test</artifactId>
<packaging>war</packaging>
<version>1.0.-SNAPSHOT</version>

<name>Test</name>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java-version>1.8</java-version>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <start-class>com.rajkishan.Application</start-class>
</properties>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.2.5.RELEASE</version>
</parent>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-log4j</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <!-- Spring Data JPA -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context-support</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
    <!--Manual-->
    <dependency>
        <groupId>com.microsoft.sqlserver</groupId>
        <artifactId>sqljdbc41</artifactId>
        <version>4.1</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <configuration>
                <showDeprecation>true</showDeprecation>
                <compilerArgs>
                    <arg>-verbose</arg>
                    <arg>-Xlint:unchecked</arg>
                </compilerArgs>
            </configuration>
        </plugin>
    </plugins>
</build>

Isn't Spring-DATA and Hibernate are different JPA impls?

like image 714
Rajkishan Swami Avatar asked Nov 26 '25 17:11

Rajkishan Swami


2 Answers

The spring-boot-starter-data-jpa POM dependency pulls in several JPA depedencies, including Hibernate. From the official Spring documentation:

The spring-boot-starter-data-jpa POM provides a quick way to get started. It provides the following key dependencies:

Hibernate — One of the most popular JPA implementations.
Spring Data JPA — Makes it easy to implement JPA-based repositories.
Spring ORMs — Core ORM support from the Spring Framework.

So the Spring data JPA JAR was intended to be one way to pull the Hibernate dependencies into your project.

like image 148
Tim Biegeleisen Avatar answered Nov 28 '25 07:11

Tim Biegeleisen


According to the spring-boot-stater-data-jpa it's have compile dependencies of hibernate-entitymanager-4.3.10.jar

Compile Dependencies of spring-boot-stater-data-jpa

And hibernate-entitymanager-4.3.10 have compile dependencies of hibernate-core-4.3.10.jar and other hiberante dependencies That's why maven Add hibernate jars

enter image description here

like image 26
Sanshayan Avatar answered Nov 28 '25 05:11

Sanshayan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!