What’s the mean of scope?
【answer】 : Scope is an attribute of dependency.
It indicates which life cycle of the project build the dependency works on.
==================================================
scope 是什么意思?
【答】:Scope 是依赖的一个属性。
它代表了这个依赖在项目的哪个生命周期起作用。
2.scope 的种类描述where does the scope appear?
【answer】 : It appears with gav of a dependency.
When it does’t appear,that’s means the dependency’s scope is compile.
=================================
scope 在哪里出现?
【答】:scope 往往和 依赖的 坐标一起出现。
当一个依赖中没有明确指明scope属性是,它的默认值 是 compile。
3.实际的例子There are three types of scopes : compile、test、provided。
compile : default. The dependency will participate in all construction phases of the project.
test : The dependency will participate in the test phases of the project only. Such as junit.
provided : The dependency will participate in the compile phase and test phase,but not the package phase.It means that the server will provide this dependency to run your program. Such as servlet依赖。
============================================================
scope有三种常见的类型 : compile、test、provided。
compile : 默认的类型。表示该依赖会伴随项目构建的整个过程,编译、测试、打包。
【对主程序有效、对测试程序有效、参与打包、参与部署】
test : 表示该依赖只会在测试阶段生效,比如 junit测试依赖。
【仅对测试程序有效】
provided : 表示该依赖会参与 项目的编译、测试阶段,但不会参与打包阶段。但是在项目部署时,该依赖会由 服务器进行提供,比如 servlet 的依赖,开发过程中需要使用,但在部署时由Tomcat服务器进行提供。
【对主程序有效、对测试程序有效、不参与打包、不参与部署】
compile类型 : 默认不写就是 compile 类型(最常见的类型)
com.alibaba
fastjson
1.2.75
test 类型 : 仅测试时使用到的
junit junit 4.11 test
provided类型 : 具体部署的服务器提供 servlet 和 jsp 。
【这种类型的依赖,如果范围使用错误了,则会导致jar包冲突的问题。】
【所以要对这种类型的依赖有特别的了解】
javax.servlet
javax.servlet-api
4.0.1
provided
javax.servlet.jsp
javax.servlet.jsp-api
2.3.3
provided
4.完成
Congratulations!
You are one step closer to success!



