我正在使用 Maven,目前遇到以下问题:
项目设置:
- master (parent project)
- module1 (parent is master)
- module2 (parent is master and needs module1 as "provided")
如以下 settings.xml 所示,我将 Artifact 作为所有 Artifact 请求的镜像。这是一种需要的方式,因为我的构建需要很少的专有 jar(并且 artifactory 负责它)。
settings.xml:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>${user.home}/.m2/repository</localRepository>
<interactiveMode>true</interactiveMode>
<usePluginRegistry>false</usePluginRegistry>
<offline>false</offline>
<mirrors>
<mirror>
<id>artifactory-virtual-repo</id>
<name>myartifactory</name>
<url>http://<artifactory-ip>:8081/artifactory/simple/<repo-name>/</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
<proxies/>
<profiles/>
<activeProfiles/>
</settings>
module1 构建良好。但是,当我尝试构建 master 或 module2 时,它会检查 Artifact 中的 module1(上面在 settings.xml 中提到的),其中这些项目仍然丢失。如何强制 eclipse (m2e) 也查看工作区项目?
换句话说,如何配置 Maven 以确保在存储库中找不到当前工作区中的 Artifact 时也会查找它?
最佳答案
一旦依赖项在 react 器中被声明为模块,Maven 就会将依赖项视为“内部”依赖项(并在项目中查找类,而不是查找 jar)。如果您的父 pom 具有以下模块声明,Maven 不应访问 Artifactory,而应使用已编译的类:
<modules>
<module>module1</module>
<module>module2</module>
</modules>
关于java - 用于查找工作区 Artifact 的 Maven settings.xml 配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16443573/