Skip to content

spring-boot-starter-velocity incompatible with spring-boot-starter-data-jpa #2814

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
stunaz opened this issue Apr 13, 2015 · 1 comment
Closed
Assignees
Milestone

Comments

@stunaz
Copy link

stunaz commented Apr 13, 2015

Hello,
Using Spring boot 1.2.3 , spring-boot-starter-velocity is incompatible with spring-boot-starter-data-jpa due to the resolved version of antlr

@wilkinsona wilkinsona self-assigned this Apr 14, 2015
@wilkinsona
Copy link
Member

I assume you're using Maven? If you order your dependencies with spring-boot-starter-data-jpa first:

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

Maven will choose to use Antlr 2.7.7. However, if you list spring-boot-starter-velocity first:

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

Maven will choose Antlr 2.7.2. This difference is because of Maven's "dependency mediation":

  • Dependency mediation - this determines what version of a dependency will be used when multiple versions of an artifact are encountered. Currently, Maven 2.0 only supports using the "nearest definition" which means that it will use the version of the closest dependency to your project in the tree of dependencies. You can always guarantee a version by declaring it explicitly in your project's POM. Note that if two dependency versions are at the same depth in the dependency tree, until Maven 2.0.8 it was not defined which one would win, but since Maven 2.0.9 it's the order in the declaration that counts: the first declaration wins.
  • "nearest definition" means that the version used will be the closest one to your project in the tree of dependencies, eg. if dependencies for A, B, and C are defined as A -> B -> C -> D 2.0 and A -> E -> D 1.0, then D 1.0 will be used when building A because the path from A to D through E is shorter. You could explicitly add a dependency to D 2.0 in A to force the use of D 2.0

If you were using Gradle you would always get 2.7.7 as, when there are multiple versions of a dependency in the graph, Gradle will choose the latest version.

There are a few ways you can fix this yourself:

  • List spring-boot-starter-data-jpa first in your pom
  • Declare your own dependency on Antlr 2.7.7
  • Declare dependency management for Antlr 2.7.7

That said, we should probably take the same approach as we have for another Hibernate dependency, javassist, and declare dependency management for the version of Antlr that Hiberate uses. For the record, the Spring IO Platform already provides such dependency management.

@wilkinsona wilkinsona added this to the 1.2.4 milestone Apr 14, 2015
bsodzik pushed a commit to bsodzik/spring-boot that referenced this issue May 23, 2015
Hibernate depends on antlr:antlr:2.7.7 (the latest version on Antlr 2)
and fails with earlier 2.7.x versions due to a missing method. This
can cause problems for Maven users if they also depend on something that
pulls in an earlier version of Antlr, such as
spring-boot-starter-velocity. Gradle users are unaffected as, when
multiple versions of a dependency are found in the graph, Gradle will
choose the latest version.

This commit adds dependency management for antlr:antlr:2.7.7 to ensure
that the latest, and Hibernate compatible, version of Antlr 2 is used.

Closes spring-projectsgh-2814
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants