我很困惑,因为看来我做对了所有事情。
我正在尝试使用IDEA构建一个Maven Hello World项目。我有我的pom.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.anarion</groupId>
<artifactId>MavenDemo</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies>
</project>
我的目录:
测试类已放置在测试目录下。 HelloMavenTest.java:
package com;
import static org.junit.*;
public class HelloMavenTest {
@org.junit.Test
public void hello() {
}
}
想法不断给我这个错误:
java: package org.junit does not exist
我不知道我在哪里弄错了...
答案 0 :(得分:0)
根据以下链接https://mvnrepository.com/artifact/junit/junit,它表示
注意:该工件已移至:
org.junit.jupiter»junit-jupiter-api
您还可以使用以下依赖项。
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.0.3</version>
<scope>test</scope>
</dependency>
您可以检查链接。
https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api/5.0.3