Systematic approach with Maven to deal with dependency hell

前端 未结 4 1704
孤独总比滥情好
孤独总比滥情好 2020-12-13 19:34

I\'m struggling with how to approach jar dependency hell. I have a Maven-IntelliJ Scala project that uses some aws sdk\'s. Recently adding the kinesis sdk has introduced inc

4条回答
  •  离开以前
    2020-12-13 19:55

    In my experience I didn't found anything fully automated, but I found the following approach quite sistematic and useful for myself:

    First of all I try to have a clear map of the project structure, relations between projects and I usually use Eclipse graphical dependency view, which tells me, for example, if a dependency is omitted for conflict with another one. Moreover it tells you the resolved dependencies for the project. I sincerely don't use IntelliJ IDEA but I believe it has a similar feature.

    Usually I try to put very common dependency higher in the structure and I exploit the feature to take care of the version for transitive dependencies, and most important, to avoid duplicates in the project structure.

    In this Maven - Manage Dependencies blog post you can find a good tutorial about dependency management.

    When adding a new dependency to my project , as in your case, I take care of where it is added in my project structure and make changes accordingly, but in most cases the dependency management mechanism is capable of deal with this problem.

    In this Maven Best Practices blog post you can find:

    Maven's dependencyManagement section allows a parent pom.xml to define dependencies that are potentially reused in child projects. This avoids duplication; without the dependencyManagement section, each child project has to define its own dependency and duplicate the version, scope, and type of the dependency.

    Obviously if you need a particular version of a dependency for a project you can always specify the version you need locally, deep in the hierarchy.

    I agree with you, it could be quite tedious, but dependency management could give you a good help.

提交回复
热议问题