我正在用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/... –