Are there any reasons to keep explicit dependency declaration for my own transitive dependencies in Maven?

后端 未结 1 589
轻奢々
轻奢々 2021-02-09 00:55

I have been reading for a while about an explicit versus transitive (implicit) dependency declaration in Maven. Most of the people tend to agree that you should always explicitl

1条回答
  •  失恋的感觉
    2021-02-09 01:13

    You've got a few questions here, so I'll try and answer them all.

    That is perfectly reasonable, but how should we tackle our internal dependencies?

    It looks like you have a module based project. To mitigate version conflicts I would suggest one of 2 possibilities:

    1. Put your common dependencies in your parent modules dependencyManagement section, and use properties for your versions.
    2. Use a base pom, and put your dependencies in its dependencyManagement section.

    Check this answer out for more information.

    My gut is telling me - get rid of the dependency spaghetti. Anyone will prove me wrong?

    I think this is a subjective question, and may have been asked before but I'll still give my opinion.

    No. I think you're on the right track. I'm not totally sold on the "declare your transitive dependencies if you're using them" opinion. One of the great benefits of using maven is that you get the transitive dependencies. If you had to declare dependencies for everything you used, I'd imagine that your poms would grow to be unmanageable beasts pretty quickly.

    The question is: should I declare xml-helper:1.1 as a dependency in core's and logic's pom.xml?

    Again, I would lean towards using dependencyManagement as opposed to declaration in each pom.

    I hope this helps!

    0 讨论(0)
提交回复
热议问题