------------------------siwuxie095
依赖范围
1、Maven 在编译、测试和运行时,分别使用三种不同的 classpath
(1)编译 classpath
(2)测试 classpath
(3)运行 classpath
2、依赖范围就是用来控制依赖与上述三种 classpath 的关系
(1)compile:编译依赖范围(默认依赖范围)
对编译、测试、运行三种 classpath 都有效,典型:spring-core
(2)test:测试依赖范围
只对测试 classpath 有效,典型:junit
(3)provided:已提供依赖范围
对编译、测试两种 classpath 有效,对运行 classpath 无效,典型:servlet-api
(4)runtime:运行时依赖范围
对测试、运行两种 classpath 有效,对编译 classpath 无效,典型:JDBC 驱动
(5)system:系统依赖范围
1)对编译、测试两种 classpath 有效,对运行 classpath 无效
2)使用时必须通过 systemPath 标签显式指定依赖文件的路径
「其实就是本机上除了 Maven 仓库之外的类库」
3、依赖范围和 classpath 的关系表
依赖范围  | 编译 classpath  | 测试 classpath  | 运行 classpath  | 例子  | 
compile  | √  | √  | √  | spring-core  | 
test  | ×  | √  | ×  | junit  | 
provided  | √  | √  | ×  | servlet-api  | 
runtime  | ×  | √  | √  | JDBC 驱动  | 
system  | √  | √  | ×  | 本机除 Maven 仓库外的类库  | 
【made by siwuxie095】
原文:http://www.cnblogs.com/siwuxie095/p/7573483.html