Maven在配置pom时需要有dependency依赖的配置,其中有依赖的作用范围,一共有五种范围。
1. compile(编译范围)
compile是默认的范围;如果没有提供一个范围,那该依赖的范围就是编译范围。编译范围依赖在所有的classpath中可用,同时它们也会被打包。
2. provided(已提供范围)
provided依赖只有在当JDK或者一个容器已提供该依赖之后才使用。例如,如果你开发了一个web应用,你可能在编译classpath中需要可用的Servlet API来编译一个servlet,但是你不会想要在打包好的WAR中包含这个Servlet API;这个
Servlet API JAR由你的应用服务器或者servlet容器提供。已提供范围的依赖在编译classpath(不是运行时)可用。它们不是传递性的,也不会被打包。
3. runtime(运行时范围)
runtime依赖在运行和测试系统的时候需要,但在编译的时候不需要。比如,你可能在编译的时候只需要JDBC API JAR,而只有在运行的时候才需要JDBC驱动实现。
4. test(测试范围)
test范围依赖 在一般的 编译和运行时都不需要,它们只有在测试编译和测试运行阶段可用。
5. system(系统范围)
system范围依赖与provided类似,但是你必须显式的提供一个对于本地系统中
JAR文件的路径。这么做是为了允许基于本地对象编译,而这些对象是系统类库
的一部分。这样的构件应该是一直可用的,Maven也不会在仓库中去寻找它。。如
果你将一个依赖范围设置成系统范围,你必须同时提供一个systemPath元素。注
意该范围是不推荐使用的(你应该一直尽量去从公共或定制的Maven仓库中引用
依赖)。
分享到:
相关推荐
NULL 博文链接:https://dannyhz.iteye.com/blog/2249427
在POM 4中,<dependency>中还引入了<scope>,它主要管理依赖的部署。目前<scope>可以使用5个值: • compile,缺省值,适用于所有阶段,会随着项目一起发布。 • provided,类似compile,期望JDK、容器或使用者会...
Maven项目管理工具,可以将一个完整的项目拆成一个一个模块进行开发,而一些比较通用的模块就可以作为公用组件。在其他项目中直接依赖使用,比如:公用的方法,权限组件等等。 一,新建一个简单的Maven工程,这个...
本教程是基于MyEclipse环境下基于maven搭建的springmvc步骤(图文教程),文章结尾含有源码下载地址: 新建maven project File->New->Project 选择Maven Project 选择项目路径 Use default Workspace location默认...
Maven依赖管理 (Dependency Management) 3.5.6. 站点生成和报告 (Site Generation and Reporting) 3.6. 小结 4. 定制一个Maven项目 4.1. 介绍 4.1.1. 下载本章样例 4.2. 定义Simple Weather项目 4.2.1...
6. 新增Dependency Scope 这点也比较重要,有些用于test范围的包,可以不用加入依赖了 7. 传递依赖,简化依赖管理 这是最为方便的,可以省了很多配置。如a 依赖 b,b 依赖c 默认 a也会依赖 c。但是也会带来隐患,...
<scope>test</scope> </dependency> <dependency> <groupId>javax.servlet <artifactId>javax.servlet-api <version>3.1.0 </dependency> <!-- mybatis依赖的jar包 --> <dependency> <groupId>org....
Dependency management - including transitive dependencies, scope recognition and SNAPSHOT handling Artifact deployment - deployment to a Maven repository (file integrated, other with extensions) POM ...
<scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot <artifactId>spring-boot-starter-web </dependency> <dependency> <groupId>org.springframework.boot <artifactId>...
* [MNG-4953] - Issue a warning when a system-scope dependency refers to the project basedir ** New Feature * [MNG-4936] - Allow to better monitor and adjust a Maven build during CI * [MNG-4937] - ...
Dependency management - including transitive dependencies, scope recognition and SNAPSHOT handling Artifact deployment - deployment to a Maven repository (file integrated, other with extensions) POM ...
跑批项目打了jar包后,运行一直找不到主类或者找不到classpath下的依赖。 解决方法: ... <scope>runtime</scope> </dependencySet> <directory>src/main/bin <outputDirectory>/ </assembly>
maven 导入 <dependency> <groupId>com.kingbase8.jdbc</groupId> <artifactId>kingbase8 <version>8.6.0 <scope>system</scope> ${basedir}/src/main/resources/jar/kingbase8-8.6.0.jar </dependency> jdbc ...
ssm在maven项目管理下的pom文件,jar包依赖 <dependency> <groupId>javax.servlet <artifactId>javax.servlet-api <version>3.1.0 <scope>provided</scope> </dependency> <dependency> <groupId>javax....
<scope>system</scope> ${JAVA_HOME}/lib/tools.jar </dependency> <dependency> <groupId>junit <artifactId>junit <version>3.8.1 <scope>test</scope> </dependency> </project>
<scope>provided</scope> </dependency> <!-- 如果不添加此节点mybatis的mapper.xml文件都会被漏掉。 --> <directory>src/main/java **/*.properties **/*.xml <filtering>false ...
<dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> <scope>test</scope> </dependency>数据库: MYSQL(5.xx) ; NoSQL : Redis (并非用的很多);其他工具推荐谷歌...
<scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot <artifactId>spring-boot-starter-web </dependency> <dependency> <groupId>mysql ...
除了项目构建,Maven最核心的功能是软件包的依赖管理,能够自动分析项目所需要的依赖软件包,并到Maven中心仓库去下载。 A)管理依赖的jar包 B)管理工程之间的依赖关系。 3.2. Maven本地仓库 在当前系统用户的...
J2V8 是 V8 引擎的 Java ...Maven:<dependency> <groupId>com.eclipsesource.j2v8</groupId> <artifactId>j2v8_win32_x86_64 <version>2.2.1 <scope>compile</scope> </dependency> 标签:J2V8