英文:
JUnit dependency not available in Maven project
问题
我已经重建了Maven仓库,但是我的Maven仍然看不到JUnit:
我使用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:
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
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.8.1</version>
<scope>test</scope>
</dependency>
答案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
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论