A project has a large number of transitive dependencies, leading to slow build times and a bloated final artifact. What is the best approach to address this performance issue?
Java interview question for Advanced practice.
Answer
Analyze the dependency tree, identify and exclude unnecessary transitive dependencies, and consider refactoring to a more modular design.
Explanation
Option D correctly identifies the root cause and solution. Excessive transitive dependencies significantly increase the application's size and complexity, leading to performance issues. Analyzing the dependency graph (mvn dependency:tree or gradle dependencies) to find and exclude unneeded libraries is a critical optimization step. Option A is false. Options B and C do not address the fundamental problem of dependency bloat.