我用 maven 收到以下错误
[WARNING] The POM for com.something:dependency_module:jar:103 is invalid, transitive dependencies (if any) will not be available: 2 problems were encountered while building the effective model for something:dependency_module:103 [ERROR] 'dependencies.dependency.systemPath' for org.jacorb:jacorb:jar must specify an absolute path but is ${jacorb2.3.1.home}/lib/jacorb.jar @ [ERROR] 'dependencyManagement.dependencies.dependency.systemPath' for org.jacorb:jacorb:jar must specify an absolute path but is ${jacorb2.3.1.home}/lib/jacorb.jar @
The problem seems to be that ${jacorb2.3.1.home} is not resolved. But the variable is actually set in the settings.xml.
<profile>
<id>jacorb2.3.1</id>
<properties>
<jacorb2.3.1.home>C:\apps\jacorb-2.3.1\</jacorb2.3.1.home>
</properties>
</profile>
事实上,项目实际上编译得很好。似乎只有在读取依赖模块的 POM 时才会抛出此错误。
请帮助我了解为什么会发生这种情况以及如何解决它。
(注意:在依赖模块 POM 中添加属性似乎可以解决此问题,但我不想在项目设置中硬编码路径)
最佳答案
通常你只将 systemPath 用于 javahome 中的工具 jar 之类的东西。
为了支持位置透明和可重复构建,systemPath 中的任何内容都非常本地化。
通常我会在共享的本地存储库(nexus 或 artifactory)中添加 3rd 方库,或者只是使用 mvn install:install 在本地安装它们(可能创建一个 shell 脚本,以便其他人可以在他们的构建中执行相同的操作)。毋庸置疑,第一个是最可持续的解决方案。
http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
关于maven dependency.systemPath 必须指定绝对路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21547364/