Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何解决maven的构建错误?_Java_Maven_Build_Pom.xml - Fatal编程技术网

Java 如何解决maven的构建错误?

Java 如何解决maven的构建错误?,java,maven,build,pom.xml,Java,Maven,Build,Pom.xml,我试着和Maven一起建立一个项目。在pom.xml文件所在的文件夹中,我启动了git bash并使用了“mvn compile”命令,但生成失败,并显示以下消息: [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] error: Source option 5 is no longer supported. Use 6 or later.

我试着和Maven一起建立一个项目。在pom.xml文件所在的文件夹中,我启动了git bash并使用了“mvn compile”命令,但生成失败,并显示以下消息:

[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] error: Source option 5 is no longer supported. Use 6 or later.
[ERROR] error: Target option 1.5 is no longer supported. Use 1.6 or later.
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 46.905 s
[INFO] Finished at: 2019-11-12T10:21:58+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project unitime: Compilation failure: Compilation failure:
[ERROR] error: Source option 5 is no longer supported. Use 6 or later.
[ERROR] error: Target option 1.5 is no longer supported. Use 1.6 or later.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

pom.xml
文件的
maven编译器插件中添加一个配置部分,并将源代码和目标代码设置为例如1.8

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>

org.apache.maven.plugins
maven编译器插件
1.8
1.8

您的Java版本也是1.8吗?我的jdk是11.0。2@Giuseppe在您提供的pom.xml()中,您可以找到我在上面的评论中提供的部分。如您所见,源和目标设置为1.5。只需将其更改为1.6或更高版本,然后尝试运行“mvn编译”。您使用的是哪个JDK版本?存储库,这里有pom.xml文件;我正在使用JDK11.0.2