无法从父级解析 junit

发布于 2025-01-12 09:14:20 字数 602 浏览 2 评论 0原文

我有父项目和 4 个子模块。我在父模块中添加了 junit 依赖项,如下所示:

<dependencys>
<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.12</version>
    <scope>test</scope>
</dependency>
</dependencys>

现在我正在子模块中测试一些 java 类,并且在 eclipse 中收到错误消息:

The import org.junit cannot be resolved

我是否必须向所有子模块添加 junit 依赖项,或者最佳实践是什么? 输入图片此处描述

I have parent project and 4 children modules. I have added junit dependency in parent like this:

<dependencys>
<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.12</version>
    <scope>test</scope>
</dependency>
</dependencys>

Now I am testing some java classes in childreen modules and I get error messsage in eclipse:

The import org.junit cannot be resolved

Do I have to add junit dependency to all children modules or what is the best practice?
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

辞别 2025-01-19 09:14:20

将 junit 依赖项从 dependencyManagement 移动到依赖项应该可以解决问题

move junit dependency from dependencyManagement to dependencies should solve the problem

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文