错误“不再支持源选项 5.使用 6 或更高版本"在 Maven 上编译 [英] Error "Source option 5 is no longer supported. Use 6 or later" on Maven compile

查看:29
本文介绍了错误“不再支持源选项 5.使用 6 或更高版本"在 Maven 上编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 $ mvn compile 上收到以下错误:

I am getting the following error on $ mvn compile:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Sym360: Compilation failure: Compilation failure: 
[ERROR] Source option 5 is no longer supported. Use 6 or later.
[ERROR] Target option 1.5 is no longer supported. Use 1.6 or later.
[ERROR] -> [Help 1]

这是我的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/maven-v4_0_0.xsd">
 <modelVersion>4.0.0</modelVersion>
 <groupId>com.test.app</groupId>
 <artifactId>Tset</artifactId>
 <packaging>jar</packaging>
 <version>1.0-SNAPSHOT</version>
 <name>Test</name>
 <url>http://maven.apache.org</url>

 <properties>
   <maven.compiler.source>6</maven.compiler.source>
   <maven.compiler.target>1.6</maven.compiler.target>
 </properties>

<build>
<pluginManagement>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <version>2.22.1</version>
    </plugin>
  </plugins>
</pluginManagement>
</build>
<dependencies>

<!-https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium- 
java -->
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>3.14.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>6.14.3</version>
    <scope>test</scope>
</dependency>

我尝试在 pom.xml 代码中添加属性,但仍然遇到相同的错误.有人可以帮我解决这个问题吗?提前致谢.

I tried to add properties in the pom.xml code, but still getting the same error. Can someone help me in resolving this issue? Thanks in advance.

推荐答案

这对我有帮助:

  1. 右键单击项目.
  2. 点击构建路径.
  3. 点击配置构建路径.
  4. 它会打开一个 Java 构建路径窗口.
  5. 点击左侧的 Java Compiler.
  6. 它导航到 Java Compiler 窗口,根据您的 jre 版本设置编译器合规性级别(例如,如果 java 版本为 1.8然后选择 1.8) 作为选择.
  7. 点击[应用]按钮.
  8. 点击[确定]按钮.
  9. 右键单击项目">Maven">更新项目".
  10. 右键单击项目">运行方式">Maven 安装"——pom.xml 文件正在运行,Java jar 已下载并安装到项目中.
  11. 右键单击项目">运行方式">Maven 测试"——pom.xml 文件正在运行,Java jar 已下载并安装到项目中.

然后您会收到 Build Success 消息,并且您的 Maven 项目已成功创建.

Then you got the Build Success message and your maven project is created successfully.

这篇关于错误“不再支持源选项 5.使用 6 或更高版本"在 Maven 上编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆