tomcat - why is transitive dependency not included my final war? -
somewhat similar question posted here. no answers there.
i have multi-module maven project
when run mvn dependency:tree
, see following
[info] ------------------------------------------------------------------------ [info] building service 2.2.22-snapshot [info] ------------------------------------------------------------------------ [info] +- org.apache.httpcomponents:httpclient:jar:4.3.2:compile [info] | \- commons-codec:commons-codec:jar:1.6:compile [info] ------------------------------------------------------------------------ [info] building common 2.2.22-snapshot [info] ------------------------------------------------------------------------ [info] +- com.mycompany.project:jar:2.1.115:compile +- commons-httpclient:commons-httpclient:jar:3.1:compile [info] | | \- commons-codec:commons-codec:jar:1.2:compile
no other configuration exclude library done in pom.xml. in final war/web-inf/lib
,
i see commons-codec-1.6.jar
, commons-httpclient-3.1.jar
, httpclient-4.3.2.jar
. not see commons-codec-1.2.jar
. why that?
instead of including both commons-codec jars, can lead conflicts , issues, maven's dependency mediation selected commons-codec-1.6.jar
- dependency mediation - determines version of dependency used when multiple versions of artifact encountered. currently, maven 2.0 supports using "nearest definition" means use version of closest dependency project in tree of dependencies. can guarantee version declaring explicitly in project's pom. note if 2 dependency versions @ same depth in dependency tree, until maven 2.0.8 not defined 1 win, since maven 2.0.9 it's order in declaration counts: first declaration wins.
- "nearest definition" means version used closest 1 project in tree of dependencies, eg. if dependencies a, b, , c defined -> b -> c -> d 2.0 , -> e -> d 1.0, d 1.0 used when building because path d through e shorter. explicitly add dependency d 2.0 in force use of d 2.0
Comments
Post a Comment