Learn Maven(01)

Maven 依赖管理
(1)pom.xml
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
(2)传递性依赖
一个复杂的项目将会包含很多依赖,也有可能包含 依赖于其他构件的依赖
你不必找出所有这些依赖然后把他们写到POM文件里,你只需要加上你直接依赖的那些库,
Maven会隐式的把这些库间接依赖的库也加入到你的项目中
 
 
(3) scope
 
<dependencies>
<
dependency>
<
groupId>junit</groupId>
<
artifactId>junit</artifactId>
<
version>3.8.1</version>
<scope>test</scope>
</
dependency>
</
dependencies>
 
compile(编译范围,默认)
provided(提供范围,打包的时候不会被打包)
runtime(运行时,编译的时候不需要)
test(测试范围)
system(与provided类似)
 
 
 
 

猜你喜欢

转载自toknowme.iteye.com/blog/2243726