我正在用java 9(build 9-ea + 165)构建一个使用maven 3.3.9的项目。测试运行并且构建成功。如何在JDK 9中为IntelliJ添加测试依赖关系?
但是, IntelliJ Idea 2017.1.2抱怨并且不会通过消息'该模块在其需求中没有模块'junit.jupiter.api'来编译/运行测试。
如何为IntelliJ添加此项? 是否有必要?
从POM:
<dependencies>
<!-- testing -->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>9</source>
<target>9</target>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.0.0-M4</version>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>4.12.0-M4</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
</plugins>
</build>
请分享消息的确切消息或屏幕截图,还有什么测试依赖关系是否使用? – nullpointer
你用java 8试过吗?你的来源可能吗?也许只是为了检查它是否修复了测试中的依赖关系,即使它不能编译和运行你的代码 –
你是否检查过你的maven缓存中有相关的jar包?通常〜/ .m2/repository/... –