Skip to content

spring-boot-starter-data-jpa pulls in multiple dependencies providing package 'javax.persistence' #21220

@holgerstolzenberg

Description

@holgerstolzenberg

I am using:

  • Spring Boot 2.3.M4
  • Gradle 6.3
  • AdoptOpenJDK-14

My build is using the Spring Boot and the Spring Dependency management plugin:

buildscript {
  repositories {
    maven {
      url "http://repo.spring.io/milestone"
    }
  }
  dependencies {
    classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
  }
}

plugins {
  id 'io.spring.dependency-management' version '1.0.9.RELEASE'
}

apply plugin: "org.springframework.boot"

dependencyManagement {
  imports {
    mavenBom "org.springframework.boot:spring-boot-dependencies:${springBootVersion}"
    mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
  }
}

dependencies {
   implementation('org.springframework.boot:spring-boot-starter-web') {
    exclude module: "spring-boot-starter-tomcat"
  }
  implementation 'org.springframework.boot:spring-boot-starter-jetty'
  implementation 'org.springframework.boot:spring-boot-starter-actuator'
  implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
  
  //
}

On applying Querydsl to the project I've noticed that two versions of javax.persistence.Entity are pulled into the classpath:

  • 1st via jakarta.persistence:jakarta.persistence-api as direct dependency of org.springframework.boot:spring-boot-starter-data-jpa
  • 2nd via javax.persistence:javax.persistence-api as transitive dependencies of org.hibernate:hibernate-core

This results in duplicated classes on the classpath and might cause hard to track down problems.

Please see attached screenshots.

Is that the intended behaviour? Am I missing something here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions