0

json-path 2.4.0 支持的 JDK 版本是多少?我浏览了主页https://github.com/json-path/JsonPath但我找不到支持的 JDK 版本。

为什么我要查找此信息

我在我的系统中使用 JDK15,当我尝试使用 json-path 2.4.0 时,出现编译错误:无法解析类型 java.lang.String。

在此处输入图像描述

但是,当我将编译器级别更改为 JDK8 时,问题就消失了。

在此处输入图像描述

我的 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.self.quickstart</groupId>
    <artifactId>starter</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>starter</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <!-- https://mvnrepository.com/artifact/com.jayway.jsonpath/json-path -->
        <dependency>
            <groupId>com.jayway.jsonpath</groupId>
            <artifactId>json-path</artifactId>
            <version>2.4.0</version>
        </dependency>
    </dependencies>
</project>

结果mvn clean verify

[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: 2.305 s
[INFO] Finished at: 2021-03-31T07:51:31+01:00
[INFO] Final Memory: 16M/80M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project starter: Compilation failure: Compilation failure: 
[ERROR] Source option 5 is no longer supported. Use 7 or later.
[ERROR] Target option 5 is no longer supported. Use 7 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
4

1 回答 1

0

您需要将该属性设置为maven.compiler.release您要定位的 Java 版本。否则 Maven 将假定 Java 5。

也可以看看

http://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html

你几乎可以复制/粘贴它

https://stackoverflow.com/a/51586202/927493

于 2021-03-31T07:01:06.943 回答