【发布时间】:2017-03-31 06:25:00
【问题描述】:
我有如下多模块结构化 maven 项目:
- 父级
- 服务器
- 共享
- 客户
对我来说,很明显我会为所有这些项目编写单元测试。所以我认为这足以将依赖项添加到父的 pom.xml 如下:
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
然后在每个子模块中使用它,f.e.:
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
但我在 Eclipse 中遇到错误,例如:The import org.junit cannot be resolved
当我做 Maven-> 更新项目时,或者mvn clean install,完全没有错误。
我在子模块中引用父模块如下:
<parent>
<groupId>pl.daniel.erp</groupId>
<artifactId>erp</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
请帮忙
【问题讨论】:
-
你在子 poms 中声明了父级吗?
-
我已经更新了检查后。谢谢
-
嗯。我会通过:stackoverflow.com/questions/3211643/…,如果这不是问题,请尝试从 Eclipse 进行完全干净的构建。可能是一个愚蠢的配置问题或 Eclipse 出现故障并需要彻底清理。
-
你在父模块pom中声明子模块依赖了吗?
-
你的意思是“
”?是的。
标签: java eclipse maven multi-module