【发布时间】:2026-02-09 20:25:01
【问题描述】:
我们有一个带有 Git 子模块 contrib/holo-everywhere 和 contrib/ActionBarSherlock 的 maven 项目
根 pom.xml 描述这样的模块:
<module>contrib/holo-everywhere/resbuilder</module>
<module>contrib/holo-everywhere/library</module>
<module>contrib/holo-everywhere/addons/preferences</module>
<module>contrib/holo-everywhere/addons/slidingmenu</module>
<module>contrib/ActionBarSherlock/actionbarsherlock</module>
从控制台构建的 maven 可以完美运行,但是当项目导入 IntelliJ IDEA 时会发生错误。
像contrib/ActionBarSherlock/actionbarsherlock/pom.xml 这样的每个 pom.xml 都无法从其项目父 pom 中的依赖管理中解析依赖版本。在这种情况下,它是contrib/ActionBarSherlock/pom.xml
contrib/ActionBarSherlock/pom.xml
<dependency>
<groupId>android</groupId>
<artifactId>android</artifactId>
<version>${android.version}</version>
</dependency>
contrib/ActionBarSherlock/actionbarsherlock/pom.xml
<dependency>
<groupId>android</groupId>
<artifactId>android</artifactId>
<scope>provided</scope>
</dependency>
这只发生在contrib 目录中的这些子模块上。我们有依赖于父 pom 的 maven 模块 - 它们的依赖关系得到了很好的解决。
这是一个错误还是我应该以其他方式导入项目?
【问题讨论】:
-
在
contrib/ActionBarSherlock/pom.xml处,您是在项目级别的<dependencies>下还是<dependencyManagement>下定义<dependency>? -
在
<dependencyManagement>下。在 ActionBarSherlock 和 holo-everywhere
标签: android maven intellij-idea