Maven 3.0.3 使用旧的 JUnit 插件,它没有 org.junit.* 包

发布于 2024-12-27 22:12:26 字数 643 浏览 5 评论 0原文

我正在使用 Hudson 并尝试从 subversion 存储库构建一个 Maven 项目。 问题是,我猜 Maven 下载了旧的 junit 版本,因为我发现了这个:

下载:..repo1.maven.org/maven2/junit/junit/3.8.1/junit-3.8.1.pom 下载:..repo1.maven.org/maven2/junit/junit/3.8.1/junit-3.8.1.pom(998 B,2.0 KB/秒)

后来它抱怨包 org.junit.* 不存在。

当我让 Hudson 构建该项目的本地副本(不是 subversion 管理)时,它会启动 junit 测试:

TESTS

Running JUnitTest ...

我的 pom.xml 看起来像这样:

http://codeviewer.org/view/code:2227< /a>

(我也尝试过 朱尼特 4.8.2 没有方括号,这没有任何帮助。 )

如何运行 JUnit 测试?

I'm using Hudson and trying to build a maven project from subversion repository.
Problem is, that Maven downloads an old junit version, I guess, because I found this:

Downloading: ..repo1.maven.org/maven2/junit/junit/3.8.1/junit-3.8.1.pom
Downloaded: ..repo1.maven.org/maven2/junit/junit/3.8.1/junit-3.8.1.pom (998 B at 2.0 KB/sec)

Later it complains that package org.junit.* doesn't exist.

When I instead let Hudson built a local copy of this project (not subversion managed), it starts the junit test:

T E S T S

Running JUnitTest
...

My pom.xml looks like this:

http://codeviewer.org/view/code:2227

(I also tried
junit
4.8.2
without the square brackets, which didn't help anything.
)

How do I get the JUnit Tests to run?

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

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

发布评论

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

评论(1

韵柒 2025-01-03 22:12:26

虽然 pom 中指定了 4.8.2 版本的 junit dependency,但它位于 标记之间。因此,除非在构建中显式定义依赖项,否则不会使用该版本。

您可以通过两种方式解决该问题。

删除外部 标记 - 仅保留内容。

除了 pom 文件中 标记之间存在的内容之外,还定义以下内容。

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
    </dependency>
</dependencies>

Pom 参考

Though junit dependency with 4.8.2 version is specified in the pom, it is between <dependencyManagement> tag. As such that version will not be used, unless the dependendency is explicitly defined in the build.

You could fix the problem in two ways.

Remove the outer <dependencyManagement> tag - just retain the contents.

Define the following in addition to what is present in the pom file between <dependencyManagement> and <build> tags.

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
    </dependency>
</dependencies>

Pom reference

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