Scrivio Interview library
DebuggingIntermediate7 min read · updated 12 November 2026

Gradle resolves jackson-databind to 2.17 but a module was tested with 2.15 and a library needs 2.18. Explain Gradle's default conflict resolution and the tools to control and inspect it.

By default Gradle resolves a version conflict by picking the highest version requested anywhere in the dependency graph, unlike Maven, which picks the one nearest to the root. So if a library asks for 2.18 and we still get 2.17, something stronger than a normal request is in play, usually a BOM applied by the dependency management plugin, an enforced platform or a strict version. dependencyInsight shows who asked for what and why a version won, and platforms, rich versions, failOnVersionConflict and dependency locking let us control the result.

Why this question is asked

Jackson is the library that most often shows up in version conflicts in Spring applications, because nearly every library depends on it. A wrong version usually fails late, with a NoSuchMethodError or a missing class at runtime, far from the build file that caused it. Interviewers use this scenario to see whether we know how Gradle really picks versions and can find the cause instead of adding random exclusions. In this answer, we will recap how conflicts arise, see Gradle's default rule, use dependencyInsight to explain our 2.17, and then go through the tools to control and freeze versions.

1A Quick Recap: Where Conflicts Come From

Our module rarely asks for jackson-databind only once. We may declare it directly, Spring Boot's starters bring it in, and a reporting library depends on it too. Each of these is a request for some version. The dependency graph is the tree of all these requests, and since only one jackson-databind jar can be on the classpath, Gradle has to pick one version. That decision is conflict resolution.

In our scenario, three numbers are involved: our module was tested with 2.15, a library we use was built against 2.18, and Gradle resolved 2.17. Each choice can break something, so we need to know exactly why 2.17 won before we change anything.

2Gradle's Default: The Highest Version Wins

Without any extra rules, Gradle picks the highest version among all requests in the graph. If our module asks for 2.15.4 and the library asks for 2.18.2, the result is 2.18.2. The reasoning is that libraries are usually backwards compatible, so the newest version requested is the one most likely to satisfy everyone.

Maven works differently. It uses nearest wins: the version declared closest to the root of the tree is chosen, even if it is lower. A direct declaration of 2.15.4 in our pom would beat a transitive 2.18.2. Teams moving between the two tools are often surprised by this, because the same dependencies can produce different classpaths.

So in our scenario, pure Gradle rules would have given 2.18, not 2.17. That tells us something else is forcing the version down.

The same requests, two tools
RequestFromGradle defaultMaven
2.15.4our build file, directloseswins: nearest to the root
2.17.2Spring Boot starter, depth 2losesloses
2.18.2report-lib, depth 2wins: highestloses
Without a BOM or platform, Gradle would pick 2.18.2 here.

3Finding Out Who Requested What

The dependencyInsight task explains the decision for one module on one configuration. We should look at runtimeClasspath, because that is what the application actually runs with.

Shell
./gradlew :app:dependencyInsight --dependency jackson-databind --configuration runtimeClasspath
# shortened output
com.fasterxml.jackson.core:jackson-databind:2.17.2 (selected by rule)
com.fasterxml.jackson.core:jackson-databind:2.15.4 -> 2.17.2
\--- runtimeClasspath
com.fasterxml.jackson.core:jackson-databind:2.18.2 -> 2.17.2
\--- com.example:report-lib:3.1.0
\--- runtimeClasspath
com.fasterxml.jackson.core:jackson-databind -> 2.17.2
\--- org.springframework.boot:spring-boot-starter-json:3.3.x
\--- runtimeClasspath

Notice the arrows: 2.18.2 -> 2.17.2 means the library asked for 2.18.2 and got 2.17.2. The selection reason, selected by rule, is the clue. The io.spring.dependency-management plugin applies the Spring Boot BOM like Maven does, overriding every request with the version the BOM manages, and it does this through a resolution rule. So the Boot version in use manages 2.17, and that beats the library's request for 2.18. An enforcedPlatform or a strictly constraint would also show here, with its own reason. The exact wording of the reasons can vary by Gradle version, but the arrows and the requesting path are always there.

4Controlling the Version With Platforms and Rich Versions

Now we can decide. Since the library needs 2.18 and our module was tested with 2.15, the safest answer is usually to move the whole Jackson family to 2.18 and run our tests on it. Jackson publishes a BOM, and importing it as a platform aligns all Jackson modules to one version.

Java
dependencies {
implementation(platform("org.springframework.boot:spring-boot-dependencies:3.5.0"))
implementation(platform("com.fasterxml.jackson:jackson-bom:2.18.2")) // aligns databind, core, annotations, modules
implementation("com.fasterxml.jackson.core:jackson-databind") // no version: the platforms supply it
// Rich versions express stronger intent on a single module:
// implementation("g:a") { version { require("2.18.0") } } // at least 2.18.0, higher allowed
// implementation("g:a") { version { prefer("2.18.2") } } // use if nobody asks for something else
// implementation("g:a") { version { strictly("2.18.2") } } // exactly this; fail if impossible
// implementation("g:a") { version { reject("2.17.0") } } // never this one
}
// runtimeClasspath: jackson-databind 2.18.2, jackson-core 2.18.2, jackson-annotations 2.18.2

A platform is a set of version recommendations that takes part in resolution: it adds constraints to the graph, so a transitive request for Jackson is aligned as well. With normal platform(), the highest-wins rule still applies between the platform's constraint and other requests. With enforcedPlatform(), the platform's versions override everything, which is the Maven-style behaviour and is best kept to applications, never libraries. With the Spring dependency management plugin, the Boot BOM's versions can be overridden with a property such as extra["jackson-bom.version"] = "2.18.2"; check the property name for your Boot version.

Rich versions are for single modules. require is the normal meaning of a version, a minimum. strictly pins a version and fails the build if something else demands another, which is a strong statement that belongs in applications. prefer is a soft hint, and reject excludes a version known to be broken.

5Making Conflicts Visible and Freezing the Result

Two more tools stop this from happening silently again. failOnVersionConflict makes the build fail whenever two different versions of the same module are requested, so each conflict must be resolved on purpose. On a big graph it is noisy, so many teams turn it on for a while to clean up, or only in a CI check.

Dependency locking records the exact resolved versions in a gradle.lockfile that we commit. Later builds use those versions, and a change only happens when someone runs the update command and the lockfile diff is reviewed. That protects us from a new release of some transitive library changing the classpath overnight.

Java
configurations.all {
resolutionStrategy.failOnVersionConflict()
}
dependencyLocking {
lockAllConfigurations()
}
// ./gradlew dependencies --write-locks -> writes gradle.lockfile
// ./gradlew build -> fails if resolution no longer matches the lockfile

6Follow-up questions

Why does Gradle pick the highest version instead of the nearest?

Because nearest wins depends on the shape of the tree, which is fragile: adding an unrelated direct dependency can silently downgrade a library that something deeper needs. Highest wins assumes backwards compatibility, which is usually true for libraries, and gives the same answer however the graph is arranged. When that assumption is wrong, Gradle gives us platforms, strict versions and rejects to say so explicitly.

When would you use enforcedPlatform instead of platform?

Rarely, and only in applications. enforcedPlatform overrides every request, including higher ones from libraries, which can push a library onto a version it does not support. In a library it is harmful, because it forces those versions on every consumer. In an application where the team owns the final classpath, it can be acceptable, but strict versions on the few modules that matter are usually more precise.

Can I just exclude the transitive Jackson from the library?

Excluding it only removes that one request; the remaining requests still decide the version. It is the wrong tool for picking versions and makes the build harder to understand. Exclusions are for dependencies we really do not want at all, such as a second logging backend.

7Conclusion

In this answer, we saw that Gradle picks the highest requested version by default, while Maven picks the nearest. Getting 2.17 when a library asks for 2.18 means a stronger rule, such as the Spring Boot BOM applied by the dependency management plugin, is overriding the request, and dependencyInsight on the runtimeClasspath shows the requests, the arrows and the reason. Platforms such as the Jackson BOM align a whole family of modules, enforcedPlatform forces them, rich versions such as strictly, require, prefer and reject express intent for one module, failOnVersionConflict makes conflicts explicit and dependency locking freezes the result.

What to say in the interviewAbout 80 seconds aloud

Open with

Gradle's default is simple: when several versions of the same module are requested anywhere in the graph, it takes the highest one. That is different from Maven, where the declaration nearest to the root wins.

Then, if they want more

So if the library asks for 2.18, pure Gradle rules would give 2.18, and seeing 2.17 tells me something stronger is involved. The first thing I would run is dependencyInsight for jackson-databind on the runtimeClasspath, because that is what the app runs with.

It shows every request with an arrow to the version it got, like 2.18.2 arrow 2.17.2 from report-lib, and the reason. Very often the reason is the Spring dependency management plugin applying the Boot BOM, which overrides requests the Maven way, or an enforcedPlatform or a strictly constraint. Then I decide on purpose.

Usually I align the whole Jackson family with the Jackson BOM as a platform at 2.18, or override the Boot BOM's Jackson property, and run our tests, since we were only tested on 2.15. For single modules, rich versions say what I mean: require a minimum, strictly pin, prefer a soft default, or reject a broken release.

To stop silent changes, I can turn on failOnVersionConflict during cleanup and use dependency locking so resolved versions only change through a reviewed lockfile.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Gradle user manual
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Gradle resolves jackson-databind to 2.17 but a module was tested with 2.15 and a library...": https://scrivio-interview-library.netlify.app/java/gradle/7b7500aa75/