JUnit依赖在Maven项目中不可用。

huangapple go评论67阅读模式
英文:

JUnit dependency not available in Maven project

问题

我已经重建了Maven仓库,但是我的Maven仍然看不到JUnit:

JUnit依赖在Maven项目中不可用。

我使用Eclipse IDE,
尝试重新安装库并手动安装了Maven,
替换了pom中的一部分代码,有谁知道如何解决这个问题

<dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter-api</artifactId>
    <version>5.8.1</version>
    <scope>test</scope>
</dependency>
英文:

I have already rebuilt the Maven repository, but my Maven still does not see JUnit:

JUnit依赖在Maven项目中不可用。

I use Eclipse IDE,
Tried reinstalling the library also manually installed maven,
Replaced part of the code in pom, does anyone know how to solve the problem

&lt;dependency&gt;
	&lt;groupId&gt;org.junit.jupiter&lt;/groupId&gt;
	&lt;artifactId&gt;junit-jupiter-api&lt;/artifactId&gt;
	&lt;version&gt;5.8.1&lt;/version&gt;
	&lt;scope&gt;test&lt;/scope&gt;
&lt;/dependency&gt;

答案1

得分: 2

日志显示“将2个源文件编译到C:\workspace\Reverse2\target\classes”,而不是...target\test-classes,这表明src/test被处理为主要代码,而不是测试代码。在主要代码中,作用域为test的依赖项不可用,因此出现编译错误。

在Maven中,测试代码默认位于**src/test/java**,而不是src/test

英文:

The log says Compiling 2 source files to C:\workspace\Reverse2\target\classes instead of ...target\test-classes which indicates that src/test is handled as main code, not as test code. In main code, dependencies with the scope test are not available, hence the compile error.

In Maven test code is by default in src/test/java, not in src/test.

huangapple
  • 本文由 发表于 2023年1月9日 01:39:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/75050001.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定