Maven依赖处理:scope:system

这两天和同事共同做一个maven的web项目。今天看他改了pom,新引入了依赖

			org.talend.esb
			atom-rest-client
			5.4.1-20131126135722
			system
			${basedir}/libs/atom-rest-client-5.4.1-20131126135722.jar

可以install了之后运行时有ClassNotFound的错误。缺少的正是新引入的jar包,atom-rest-client的依赖。

所以我立刻怀疑是不是scope为system时,Maven就不会处理传递依赖了。查了一下maven依赖树,果然。

在pom目录下,运行mvn dependency:tree

这个是使用默认scope时,项目的依赖树:

[INFO] ------------------------------------------------------------------------
[INFO] Building Service Registry With AngularJS UI 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ NgServiceRegistry ---
[INFO] com.talend.example:NgServiceRegistry:war:1.0-SNAPSHOT
[INFO] +- javax.servlet:servlet-api:jar:2.5:provided
[INFO] +- org.json:json:jar:20131018:compile
[INFO] \- org.talend.esb.tooling:atom-rest-client:jar:5.4.1-SNAPSHOT:compile
[INFO]    +- org.apache.cxf:cxf-rt-frontend-jaxrs:jar:2.6.2:compile
[INFO]    |  +- org.apache.cxf:cxf-api:jar:2.6.2:compile
[INFO]    |  |  +- org.codehaus.woodstox:woodstox-core-asl:jar:4.1.4:runtime
[INFO]    |  |  |  \- org.codehaus.woodstox:stax2-api:jar:3.1.1:runtime
[INFO]    |  |  +- org.apache.ws.xmlschema:xmlschema-core:jar:2.0.3:compile
[INFO]    |  |  +- org.apache.geronimo.specs:geronimo-javamail_1.4_spec:jar:1.7.1:compile
[INFO]    |  |  \- wsdl4j:wsdl4j:jar:1.6.2:compile
[INFO]    |  +- org.apache.cxf:cxf-rt-core:jar:2.6.2:compile
[INFO]    |  |  \- com.sun.xml.bind:jaxb-impl:jar:2.2.5:compile
[INFO]    |  +- javax.ws.rs:jsr311-api:jar:1.1.1:compile
[INFO]    |  +- org.apache.cxf:cxf-rt-bindings-xml:jar:2.6.2:compile
[INFO]    |  \- org.apache.cxf:cxf-rt-transports-http:jar:2.6.2:compile
[INFO]    +- org.apache.cxf:cxf-rt-rs-security-xml:jar:2.6.2:compile
[INFO]    |  \- org.apache.cxf:cxf-rt-ws-security:jar:2.6.2:compile
[INFO]    |     +- org.apache.cxf:cxf-rt-bindings-soap:jar:2.6.2:compile
[INFO]    |     |  \- org.apache.cxf:cxf-rt-databinding-jaxb:jar:2.6.2:compile
[INFO]    |     +- net.sf.ehcache:ehcache-core:jar:2.5.1:compile
[INFO]    |     |  \- org.slf4j:slf4j-api:jar:1.6.1:compile
[INFO]    |     +- org.apache.ws.security:wss4j:jar:1.6.7:compile
[INFO]    |     |  +- org.apache.santuario:xmlsec:jar:1.5.2:compile
[INFO]    |     |  \- org.opensaml:opensaml:jar:2.5.1-1:compile
[INFO]    |     |     \- org.opensaml:openws:jar:1.4.2-1:compile
[INFO]    |     |        \- org.opensaml:xmltooling:jar:1.3.2-1:compile
[INFO]    |     |           \- joda-time:joda-time:jar:1.6.2:compile
[INFO]    |     \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO]    \- rome:rome:jar:1.0:compile
[INFO]       \- jdom:jdom:jar:1.0:compile
[INFO] ------------------------------------------------------------------------
这个是依赖的scope为system时,依赖树的情况:

[INFO] ------------------------------------------------------------------------
[INFO] Building Service Registry With AngularJS UI 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ NgServiceRegistry ---
[INFO] com.talend.example:NgServiceRegistry:war:1.0-SNAPSHOT
[INFO] +- javax.servlet:servlet-api:jar:2.5:provided
[INFO] +- org.json:json:jar:20131018:compile
[INFO] \- org.talend.esb:atom-rest-client:jar:5.4.1-20131126135722:system
[INFO] ------------------------------------------------------------------------

很清楚了吧?当依赖的scope为system时,maven是不会引入依赖的依赖,也就是传递依赖的。

你可能感兴趣的:(Maven依赖处理:scope:system)