我的测试是 运行 然后我点击 "Run as --> Maven clean" 现在当我点击 "Run as --> Maven test" 它不再起作用
My tests were running and then I clicked "Run as --> Maven clean" and now when I click "Run as --> Maven test" it doesn't work anymore
我的项目在 Eclipse 中右键单击 pom.xml 文件并选择:"Run as --> Maven install" 然后选择 "Run as --> Maven test".
后成功运行
我开始试验并选择了:"Run as --> Maven clean",然后是 "Run as --> Maven install"。这一次我遇到了构建错误并且无法 运行 "Run as --> Maven test"。发生了什么?为什么我会收到构建错误?
如果我退出 Eclipse,删除 .m2 文件夹中的所有内容,重新启动 Eclipse,然后单击 "Run as --> Maven install" 两次(第一次产生错误,第二次产生错误,我可以让测试再次运行做的伎俩)。我不知道为什么会这样。我对 "Maven clean"、"Maven install" 和 "Maven test" 的作用感到困惑。是的,我已经阅读了 documentation on maven.apache.org,但我仍然感到困惑。
这是我的 pom.xml:
<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.ah</groupId>
<artifactId>goToLinks</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>GoToLinks</name>
<dependencies>
<!-- selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<!-- cucumber-java -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>5.7.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-junit -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>5.7.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
<configuration>
<parallel>methods</parallel>
<useUnlimitedThreads>true</useUnlimitedThreads>
</configuration>
</plugin>
</plugins>
</build>
</project>
这是我遇到的错误:
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] Source option 5 is no longer supported. Use 7 or later.
[ERROR] Target option 5 is no longer supported. Use 7 or later.
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.540 s
[INFO] Finished at: 2020-06-01T19:47:03-04:00
[INFO] ------------------------------------------------------------------------
maven 编译器插件默认为 Java 1.5,但您使用的 JDK 版本不再支持该版本。您可以通过将编译器插件配置为使用不同版本的 java.
来解决该问题
https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html
<project>
[...]
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
[...]
</project>
或者直接配置插件:
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
[...]
</build>
[...]
</project>
我的项目在 Eclipse 中右键单击 pom.xml 文件并选择:"Run as --> Maven install" 然后选择 "Run as --> Maven test".
后成功运行我开始试验并选择了:"Run as --> Maven clean",然后是 "Run as --> Maven install"。这一次我遇到了构建错误并且无法 运行 "Run as --> Maven test"。发生了什么?为什么我会收到构建错误?
如果我退出 Eclipse,删除 .m2 文件夹中的所有内容,重新启动 Eclipse,然后单击 "Run as --> Maven install" 两次(第一次产生错误,第二次产生错误,我可以让测试再次运行做的伎俩)。我不知道为什么会这样。我对 "Maven clean"、"Maven install" 和 "Maven test" 的作用感到困惑。是的,我已经阅读了 documentation on maven.apache.org,但我仍然感到困惑。
这是我的 pom.xml:
<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.ah</groupId>
<artifactId>goToLinks</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>GoToLinks</name>
<dependencies>
<!-- selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<!-- cucumber-java -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>5.7.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-junit -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>5.7.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
<configuration>
<parallel>methods</parallel>
<useUnlimitedThreads>true</useUnlimitedThreads>
</configuration>
</plugin>
</plugins>
</build>
</project>
这是我遇到的错误:
[INFO] ------------------------------------------------------------- [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] Source option 5 is no longer supported. Use 7 or later. [ERROR] Target option 5 is no longer supported. Use 7 or later. [INFO] 2 errors [INFO] ------------------------------------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.540 s [INFO] Finished at: 2020-06-01T19:47:03-04:00 [INFO] ------------------------------------------------------------------------
maven 编译器插件默认为 Java 1.5,但您使用的 JDK 版本不再支持该版本。您可以通过将编译器插件配置为使用不同版本的 java.
来解决该问题https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html
<project>
[...]
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
[...]
</project>
或者直接配置插件:
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
[...]
</build>
[...]
</project>