๐ธ TL;DR
The mvn dependency:analyze command can identify unused dependencies, but its bytecode-based analysis can produce misleading results in modern Spring Boot applications.
Removing an "unused" dependency could break your application! ๐ฅ
๐ธ THE PROBLEM
In this insightful article, Nicolas Frรคnkel, an Oracle ACE Associate whom I had the pleasure of seeing in person at the DevLille conference, challenges a common Maven best practice.
The command mvn dependency:analyze identifies:
โช๏ธ Used and declared dependencies โ
โช๏ธ Used but undeclared dependencies โ ๏ธ
โช๏ธ Declared but apparently unused dependencies โ
Sounds useful, right?
Unfortunately, the analyzer mainly examines compiled bytecode, missing some dependencies used through framework mechanisms.
๐ธ SPRING BOOT CHANGES THE GAME ๐
Spring Boot relies heavily on auto-configuration, conditional annotations, and classpath detection.
Nicolas demonstrates how the analyzer incorrectly flags essential dependencies in a project using:
โช๏ธ Spring Boot Data R2DBC
โช๏ธ Testcontainers PostgreSQL
โช๏ธ Testcontainers R2DBC
Remove them, and the tests stop working! ๐จ
The analyzer simply doesn't understand all the mechanisms modern frameworks use.
๐ธ TAKEAWAYS
โช๏ธ Don't blindly trust static analysis tools. Understand their limitations.
โช๏ธ Context matters. A dependency may be essential without being directly referenced.
โช๏ธ Test before removing. An "unused" warning isn't proof that a dependency is unnecessary.
โช๏ธ Modern frameworks need modern tooling. Spring Boot, Quarkus, and Micronaut introduce dependency patterns that traditional analyzers may miss.
๐ก My takeaway: Tools should support engineering judgment, not replace it.
๐ Thanks, Nicolas, for challenging an established practice with a concrete technical demonstration!
๐ Read the article:
๐ฌ Have you ever removed an apparently unused dependency only to discover it was essential?
#Java #Maven #SpringBoot #SoftwareEngineering #CleanCode #DependencyManagement #OracleACE
๐Fullstack Dev 2027 for Java Tech๐ https://a.co/d/0crUwEQ6