scope详解
Maven存在着编译、测试、打包,部署,运行等生命周期。
在这些生命周期中…
有些依赖只用于测试,比如Junit。
有些依赖只有运行时才能用到,编译用不到,比如MySQL驱动包只在运行时用到(编译后使用的是JDBC接口)
还有些依赖,编译期用到,运行期不需要,因为有些容器已经提供了,比如servlet-api在tomcat中已经提供,我们只需要在编译期使用,项目上线后由tomcat提供。
在pom.xml中,是通过dependency
中的scope
标签来管理依赖的范围。
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
<scope>test</scope>