How does Maven resolve dependency conflicts?












1















Let's assume we have a Project A.




  • Project A has a dependency on Project B version 1.0

  • Project A has a dependency on Project C version 2.0

  • Project C (version 2.0) has a dependency on Project B version 2.0


In this case, how would Maven resolve the conflict?










share|improve this question

























  • I'm not satisfied the question. According to stackoverflow.com/help/how-to-ask, you should "Explain how you encountered the problem you're trying to solve, and any difficulties that have prevented you from solving it yourself." I don't see any dififculties to prevent solve issue yourself.

    – michaldo
    Aug 10 '16 at 8:14











  • Is this a multi module build?

    – khmarbaise
    Aug 10 '16 at 8:22











  • @khmarbaise no. I have project B and project C as a dependency in the pom.xml of project A.

    – erolkaya84
    Aug 10 '16 at 8:26
















1















Let's assume we have a Project A.




  • Project A has a dependency on Project B version 1.0

  • Project A has a dependency on Project C version 2.0

  • Project C (version 2.0) has a dependency on Project B version 2.0


In this case, how would Maven resolve the conflict?










share|improve this question

























  • I'm not satisfied the question. According to stackoverflow.com/help/how-to-ask, you should "Explain how you encountered the problem you're trying to solve, and any difficulties that have prevented you from solving it yourself." I don't see any dififculties to prevent solve issue yourself.

    – michaldo
    Aug 10 '16 at 8:14











  • Is this a multi module build?

    – khmarbaise
    Aug 10 '16 at 8:22











  • @khmarbaise no. I have project B and project C as a dependency in the pom.xml of project A.

    – erolkaya84
    Aug 10 '16 at 8:26














1












1








1








Let's assume we have a Project A.




  • Project A has a dependency on Project B version 1.0

  • Project A has a dependency on Project C version 2.0

  • Project C (version 2.0) has a dependency on Project B version 2.0


In this case, how would Maven resolve the conflict?










share|improve this question
















Let's assume we have a Project A.




  • Project A has a dependency on Project B version 1.0

  • Project A has a dependency on Project C version 2.0

  • Project C (version 2.0) has a dependency on Project B version 2.0


In this case, how would Maven resolve the conflict?







maven






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 '18 at 23:38









Chris Halcrow

11.1k46990




11.1k46990










asked Aug 10 '16 at 8:06









erolkaya84erolkaya84

9441219




9441219













  • I'm not satisfied the question. According to stackoverflow.com/help/how-to-ask, you should "Explain how you encountered the problem you're trying to solve, and any difficulties that have prevented you from solving it yourself." I don't see any dififculties to prevent solve issue yourself.

    – michaldo
    Aug 10 '16 at 8:14











  • Is this a multi module build?

    – khmarbaise
    Aug 10 '16 at 8:22











  • @khmarbaise no. I have project B and project C as a dependency in the pom.xml of project A.

    – erolkaya84
    Aug 10 '16 at 8:26



















  • I'm not satisfied the question. According to stackoverflow.com/help/how-to-ask, you should "Explain how you encountered the problem you're trying to solve, and any difficulties that have prevented you from solving it yourself." I don't see any dififculties to prevent solve issue yourself.

    – michaldo
    Aug 10 '16 at 8:14











  • Is this a multi module build?

    – khmarbaise
    Aug 10 '16 at 8:22











  • @khmarbaise no. I have project B and project C as a dependency in the pom.xml of project A.

    – erolkaya84
    Aug 10 '16 at 8:26

















I'm not satisfied the question. According to stackoverflow.com/help/how-to-ask, you should "Explain how you encountered the problem you're trying to solve, and any difficulties that have prevented you from solving it yourself." I don't see any dififculties to prevent solve issue yourself.

– michaldo
Aug 10 '16 at 8:14





I'm not satisfied the question. According to stackoverflow.com/help/how-to-ask, you should "Explain how you encountered the problem you're trying to solve, and any difficulties that have prevented you from solving it yourself." I don't see any dififculties to prevent solve issue yourself.

– michaldo
Aug 10 '16 at 8:14













Is this a multi module build?

– khmarbaise
Aug 10 '16 at 8:22





Is this a multi module build?

– khmarbaise
Aug 10 '16 at 8:22













@khmarbaise no. I have project B and project C as a dependency in the pom.xml of project A.

– erolkaya84
Aug 10 '16 at 8:26





@khmarbaise no. I have project B and project C as a dependency in the pom.xml of project A.

– erolkaya84
Aug 10 '16 at 8:26












2 Answers
2






active

oldest

votes


















1














It'd build with Project B v 1.0



You can use http://maven.apache.org/plugins/maven-dependency-plugin/examples/resolving-conflicts-using-the-dependency-tree.html
to see, that it omitted B 2.0 cause 1.0 is nearer.



from page above:




by default Maven resolves version conflicts with a nearest-wins strategy.




Output'd be something like that:



[INFO] [dependency:tree]
[INFO] Project A
[INFO] +- Project-B:jar:1.0:compile
[INFO] - Project-C:jar:2.0:compile
[INFO] - (Project-B:jar:2.0:compile - ommited for conflicts with 1.0)





share|improve this answer

































    0














    I found this explanation and it was really helpful to me.




    Nearest definition means that the version used will be the closest one to your project in the tree of dependencies,



    eg. if dependencies for A, B, and C are defined as A -> B -> C -> D 2.0 and A -> E -> D 1.0, then D 1.0 will be used when building A because the path from A to D through E is shorter. You could explicitly add a dependency to D 2.0 in A to force the use of D 2.0







    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f38867595%2fhow-does-maven-resolve-dependency-conflicts%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      It'd build with Project B v 1.0



      You can use http://maven.apache.org/plugins/maven-dependency-plugin/examples/resolving-conflicts-using-the-dependency-tree.html
      to see, that it omitted B 2.0 cause 1.0 is nearer.



      from page above:




      by default Maven resolves version conflicts with a nearest-wins strategy.




      Output'd be something like that:



      [INFO] [dependency:tree]
      [INFO] Project A
      [INFO] +- Project-B:jar:1.0:compile
      [INFO] - Project-C:jar:2.0:compile
      [INFO] - (Project-B:jar:2.0:compile - ommited for conflicts with 1.0)





      share|improve this answer






























        1














        It'd build with Project B v 1.0



        You can use http://maven.apache.org/plugins/maven-dependency-plugin/examples/resolving-conflicts-using-the-dependency-tree.html
        to see, that it omitted B 2.0 cause 1.0 is nearer.



        from page above:




        by default Maven resolves version conflicts with a nearest-wins strategy.




        Output'd be something like that:



        [INFO] [dependency:tree]
        [INFO] Project A
        [INFO] +- Project-B:jar:1.0:compile
        [INFO] - Project-C:jar:2.0:compile
        [INFO] - (Project-B:jar:2.0:compile - ommited for conflicts with 1.0)





        share|improve this answer




























          1












          1








          1







          It'd build with Project B v 1.0



          You can use http://maven.apache.org/plugins/maven-dependency-plugin/examples/resolving-conflicts-using-the-dependency-tree.html
          to see, that it omitted B 2.0 cause 1.0 is nearer.



          from page above:




          by default Maven resolves version conflicts with a nearest-wins strategy.




          Output'd be something like that:



          [INFO] [dependency:tree]
          [INFO] Project A
          [INFO] +- Project-B:jar:1.0:compile
          [INFO] - Project-C:jar:2.0:compile
          [INFO] - (Project-B:jar:2.0:compile - ommited for conflicts with 1.0)





          share|improve this answer















          It'd build with Project B v 1.0



          You can use http://maven.apache.org/plugins/maven-dependency-plugin/examples/resolving-conflicts-using-the-dependency-tree.html
          to see, that it omitted B 2.0 cause 1.0 is nearer.



          from page above:




          by default Maven resolves version conflicts with a nearest-wins strategy.




          Output'd be something like that:



          [INFO] [dependency:tree]
          [INFO] Project A
          [INFO] +- Project-B:jar:1.0:compile
          [INFO] - Project-C:jar:2.0:compile
          [INFO] - (Project-B:jar:2.0:compile - ommited for conflicts with 1.0)






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Aug 10 '16 at 8:16

























          answered Aug 10 '16 at 8:08









          SarsethSarseth

          3471217




          3471217

























              0














              I found this explanation and it was really helpful to me.




              Nearest definition means that the version used will be the closest one to your project in the tree of dependencies,



              eg. if dependencies for A, B, and C are defined as A -> B -> C -> D 2.0 and A -> E -> D 1.0, then D 1.0 will be used when building A because the path from A to D through E is shorter. You could explicitly add a dependency to D 2.0 in A to force the use of D 2.0







              share|improve this answer




























                0














                I found this explanation and it was really helpful to me.




                Nearest definition means that the version used will be the closest one to your project in the tree of dependencies,



                eg. if dependencies for A, B, and C are defined as A -> B -> C -> D 2.0 and A -> E -> D 1.0, then D 1.0 will be used when building A because the path from A to D through E is shorter. You could explicitly add a dependency to D 2.0 in A to force the use of D 2.0







                share|improve this answer


























                  0












                  0








                  0







                  I found this explanation and it was really helpful to me.




                  Nearest definition means that the version used will be the closest one to your project in the tree of dependencies,



                  eg. if dependencies for A, B, and C are defined as A -> B -> C -> D 2.0 and A -> E -> D 1.0, then D 1.0 will be used when building A because the path from A to D through E is shorter. You could explicitly add a dependency to D 2.0 in A to force the use of D 2.0







                  share|improve this answer













                  I found this explanation and it was really helpful to me.




                  Nearest definition means that the version used will be the closest one to your project in the tree of dependencies,



                  eg. if dependencies for A, B, and C are defined as A -> B -> C -> D 2.0 and A -> E -> D 1.0, then D 1.0 will be used when building A because the path from A to D through E is shorter. You could explicitly add a dependency to D 2.0 in A to force the use of D 2.0








                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Aug 16 '16 at 21:33









                  erolkaya84erolkaya84

                  9441219




                  9441219






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f38867595%2fhow-does-maven-resolve-dependency-conflicts%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

                      Alcedinidae

                      Origin of the phrase “under your belt”?