maven依赖传递问题处理方式

碰到maven包依赖传递问题怎么办

1、通过查看maven的依赖树查看有哪些不必要的包

  • 命令为:mvn dependency:tree
[INFO] Scanning for projects... 
[INFO] Searching repository for plugin with prefix: 'dependency'. 
[INFO] ------------------------------------------------------------------------ 
[INFO] Building SomeCompany :: Main Webapp 
[INFO]    task-segment: [dependency:tree] 
[INFO] ------------------------------------------------------------------------ 
[INFO] [dependency:tree] 
[INFO] com.somecompany:somecompany:war:1.0-SNAPSHOT 
[INFO] +- com.somecompany:backend:jar:1.0-SNAPSHOT:compile 
[INFO] |  +- mysql:mysql-connector-java:jar:5.0.4:runtime 
[INFO] |  +- antlr:antlr:jar:2.7.6:compile 
[INFO] |  +- commons-codec:commons-codec:jar:1.3:compile 
[INFO] |  +- commons-dbcp:commons-dbcp:jar:1.2.1:compile 
[INFO] |  |  \- xml-apis:xml-apis:jar:1.0.b2:compile 
[INFO] |  +- commons-httpclient:commons-httpclient:jar:3.0:compile 
[INFO] |  |  \- junit:junit:jar:3.8.1:compile 
[INFO] |  +- commons-lang:commons-lang:jar:2.3:compile 
[INFO] |  +- commons-logging:commons-logging:jar:1.0.4:compile 
[INFO] |  +- commons-pool:commons-pool:jar:1.3:compile 
[INFO] |  +- dom4j:dom4j:jar:1.6:compile 
[INFO] |  +- net.sf.ehcache:ehcache:jar:1.4.0:compile 
[INFO] |  |  +- net.sf.jsr107cache:jsr107cache:jar:1.0:compile 
[INFO] |  |  \- backport-util-concurrent:backport-util-concurrent:jar:3.1:compile 
[INFO] |  +- org.hibernate:hibernate-annotations:jar:3.2.0.ga:compile 
[INFO] |  |  +- org.hibernate:hibernate:jar:3.2.0.ga:compile 
[INFO] |  |  |  +- javax.transaction:jta:jar:1.0.1B:compile 
[INFO] |  |  |  +- asm:asm-attrs:jar:1.5.3:compile 
[INFO] |  |  |  +- cglib:cglib:jar:2.1_3:compile 
[INFO] |  |  |  \- asm:asm:jar:1.5.3:compile 
[INFO] |  |  \- javax.persistence:persistence-api:jar:1.0:compile 
[INFO] |  +- jdom:jdom:jar:1.0:compile 
[INFO] |  +- ognl:ognl:jar:2.6.7:compile 
[INFO] |  +- rome:rome:jar:0.9:compile 
[INFO] |  +- org.springframework:spring:jar:1.2.7:compile 
[INFO] |  +- net.sourceforge.stripes:stripes:jar:1.4.3:compile 
[INFO] |  +- velocity:velocity:jar:1.5:compile 
[INFO] |  |  \- oro:oro:jar:2.0.8:compile 
[INFO] |  +- org.json:json:jar:20070829:compile 
[INFO] |  +- org.htmlparser:htmlparser:jar:1.6:compile 
[INFO] |  +- javax.mail:mail:jar:1.4:compile 
[INFO] |  |  \- javax.activation:activation:jar:1.1:compile 
[INFO] |  \- org.safehaus:jug:jar:2.0.0:compile 
[INFO] +- javax.servlet:jstl:jar:1.1.2:compile 
[INFO] +- taglibs:standard:jar:1.1.2:compile 
[INFO] +- javax.servlet:servlet-api:jar:2.5:compile 
[INFO] +- com.oreilly.servlet:cos:jar:1.0:compile 
[INFO] +- c3p0:c3p0:jar:0.9.1.2:compile 
[INFO] +- jaxen:jaxen:jar:1.1-beta-7:compile 
[INFO] |  +- xerces:xmlParserAPIs:jar:2.6.2:compile 
[INFO] |  +- xerces:xercesImpl:jar:2.6.2:compile 
[INFO] |  \- xom:xom:jar:1.0b3:compile 
[INFO] |     +- com.ibm.icu:icu4j:jar:2.6.1:compile 
[INFO] |     +- xalan:xalan:jar:2.6.0:compile 
[INFO] |     \- org.ccil.cowan.tagsoup:tagsoup:jar:0.9.7:compile 
[INFO] +- javax.sql:jdbc-stdext:jar:2.0:compile 
[INFO] +- org.apache.lucene:lucene-core:jar:1.9.1:compile 
[INFO] +- quartz:quartz:jar:1.5.1:compile 
[INFO] +- commons-collections:commons-collections:jar:3.2:compile 
[INFO] +- org.apache.avalon.logkit:avalon-logkit:jar:2.2.1:compile 
[INFO] +- jgroups:jgroups-all:jar:2.6.1:compile 
[INFO] \- log4j:log4j:jar:1.2.11:compile 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESSFUL 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 4 seconds 
[INFO] Finished at: Wed Apr 30 16:40:42 PDT 2008 
[INFO] Final Memory: 12M/508M 
[INFO] ------------------------------------------------------------------------

2、通过标签去除掉不必要的jar包依赖

<exclusions>
                <exclusion>
                    <artifactId>mongo-java-driver</artifactId>
                    <groupId>org.mongodb</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>spring-data-mongodb</artifactId>
                    <groupId>org.springframework.data</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>solr-solrj</artifactId>
                    <groupId>org.apache.solr</groupId>
                </exclusion>
            </exclusions>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值