我有一个关于 Maven pom.xml 的问题。
我在 pom.xml 中添加了一个依赖项,例如:
<dependencies>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>features-restconf</artifactId>
<version>1.2.1-Lithium-SR1</version>
<classifier>features</classifier>
<type>xml</type>
<scope>runtime</scope>
</dependency>
</dependencies>
我无法理解 <classifier> 和 <type> 的用法。
我的问题是:
- 分类器和类型的含义是什么
- 类型是 xml 时范围(运行时)的含义是什么。我猜 xml 意味着 maven 需要一个 xml 文件,但它与 运行时有什么关系?我认为运行时总是与“添加到类路径”相关联,但为什么是 xml?
如果我对 < type > 发表评论,我会收到如下错误:
[错误] 未能在项目测试中执行目标:无法解析项目 com.ruan:test:jar:1.0-SNAPSHOT 的依赖项:未能找到 org.opendaylight.controller:features-restconf:jar:features:1.2.1- http://nexus.opendaylight.org/content/repositories/public/中的Lithium-SR1已缓存在本地存储库中,直到 opendaylight-mirror 的更新间隔已过或强制更新后才会重新尝试解析 -> [帮助1]
如果我对 <classifier> 发表评论,我会收到如下错误:
[错误] 未能在项目测试中执行目标:无法解析项目 com.ruan:test:jar:1.0-SNAPSHOT 的依赖项:未能找到 org.opendaylight.controller:features-restconf:xml:1.2.1-Lithium- http://nexus.opendaylight.org/content/repositories/public/中的SR1 被缓存在本地存储库中,直到 opendaylight-mirror 的更新间隔已过或强制更新后才会重新尝试解析 -> [帮助 1]
如果我正确运行它,我会得到如下目录:
haoruan:~/.m2/repository/org/opendaylight/controller/features-restconf $ cd 1.2.1-Lithium-SR1/
total 96
-rw-r--r-- 1 haoruan staff 264B Oct 29 13:58 _remote.repositories
-rw-r--r-- 1 haoruan staff 397B Oct 29 13:38 features-restconf-1.2.1-Lithium-SR1-features.jar.lastUpdated
-rw-r--r-- 1 haoruan staff 9.0K Oct 29 13:58 features-restconf-1.2.1-Lithium-SR1-features.xml
-rw-r--r-- 1 haoruan staff 40B Oct 29 13:58 features-restconf-1.2.1-Lithium-SR1-features.xml.sha1
-rw-r--r-- 1 haoruan staff 12K Oct 29 13:38 features-restconf-1.2.1-Lithium-SR1.pom
-rw-r--r-- 1 haoruan staff 40B Oct 29 13:38 features-restconf-1.2.1-Lithium-SR1.pom.sha1
-rw-r--r-- 1 haoruan staff 397B Oct 29 13:39 features-restconf-1.2.1-Lithium-SR1.xml.lastUpdated