简体   繁体   中英

Maven Dependency Management : Transitive Vs Direct Dependency

Consider a war application having following dependency.

War A --> Jar A --> jar B

War A adds dependency of Jar A only. Gets jar B as transitive dependency. But let's say something changes in B, then we need to build A with new version of B.Is this right thing to do? Every time B changes, A's pom needs to pick latest changes of B. Should War A specify direct dependency of A and B both or just A?

Is there some rule which says like we should ideally declare direct dependency of only those jar of which we are directly using the API of.

In above case, there is java class from jar B which is getting called from war A.

Please help with my understanding.

In general, it's best to keep maven's convention, and allow it to resolve transitive dependencies, so you don't swirl into a dependency hell!
If you want to test a change, you can, for testing purposes, add a direct dependency.

Keep it simple. Allow maven to manage this.

I hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM