Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9231581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:06:24+00:00 2026-06-18T06:06:24+00:00

We encountered a situation where Maven chose an inconsistent version of an indirect dependency,

  • 0

We encountered a situation where Maven chose an inconsistent version of an indirect dependency, and I’d like to understand why, and how to prevent this in the future.

Our pom.xml file had the following dependencies:

<dependency>
  <groupId>org.springframework.data</groupId>
  <artifactId>spring-data-jpa</artifactId>
  <version>1.1.0.RELEASE</version>
</dependency> 
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-web</artifactId>
  <version>3.1.2.RELEASE</version>
</dependency>

but without a direct dependency on spring-core.

Both depend on spring-core: spring-web 3.1.2.RELEASE depends on spring-core 3.1.2.RELEASE (see its pom-file), and spring-data-jpa 1.1.0.RELEASE depends on an arbitrary 3.x version of spring-core (to be precise [3.0.7.RELEASE,4.0.0.RELEASE), see its pom-file).

Combining both, I would expect Maven to choose spring-core version 3.1.2.RELEASE. However, it does not. Instead, it chooses the highest from the range [3.0.7.RELEASE,4.0.0.RELEASE), which currently is 3.2.0.RELEASE.

(Reproduction scenario: put the above pom.xml file (gist) in its own directory, and run mvn dependency:tree -Dverbose=true: for me the result is this tree (gist). I get the same result for both Maven 2.2.1 on Linux and Maven 3.0.4 on Windows.)

This seems wrong, because it is inconsistent: a version of spring-core which spring-web’s pom-file does not allow is used.

(This occurred for us when spring-core 3.2.0.RC1 became available: on the next update it was suddenly selected, and we were lucky that we got a build error because of an incompatible change between spring-core 3.1 and 3.2. But next time we may not be so lucky, and have runtime errors which are very difficult to track down.)

Urghh: I just notice that the order of <dependency> declarations matters: if I put spring-web first, then spring-core 3.1.2.RELEASE is selected. What gives?

Question: How can we make Maven choose consistent versions of indirect dependencies, or at least warn if it makes a choice which goes against a version specified in a pom-file?

Update: I am asking for a general solution here. For this specific case, I know that I can get the correct behavior by adding a dependency in <dependencyManagement>, specifying that I always want spring-core 3.1.2.RELEASE. However, I would like Maven to do the Right Thing (TM) without such specific declarations.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:06:25+00:00Added an answer on June 18, 2026 at 6:06 am

    What you expect seems logic but Maven has no chance to do this. It just resolves dependencies without the knowledge that spring-data-jpa might have somethig to do with spring-core.

    The dependency resolution works as describe here and is the way you already described:

    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.

    So I think the only way to prevent this situation is to be aware of it and to explecitly set the version you need in your own pom.

    By the way, why do you think “This seems wrong, because it is inconsistent: a version of spring-core is used which spring-web’s pom-file does not allow.“?

    A version specification of <version>x.y</version> is only a recommendation (see ‘Note’ here) to use this version. If you intend to force to use this version you have to set <version>[x.y]</version>.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We've encountered the following situation in our database. We have table 'A' and table
I am developing my stuff in python. In this process I encountered a situation
I've encountered this situation so many times... enum Fruit { Apple, Banana, Pear, Tomato
Many of you probably encountered this situation. For example you have a jQuery fade
Has anyone ever encountered a situation where this code doesn't work: $('#whatever').css({ left:'+=7px' });
I have worked with various applications and encountered this situation many times. Until now
I just encountered this strange situation: I found an example, where wx.Frame's OnPaint is
I'm encountered with this situation: (fn produce [] '(val0 val1)) ;... (loop [ arg0
I recently encountered a situation in some code I am working on that doesn't
I've encountered a situation, when Page's design completely hides Trace info. I'm looking for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.