最先出现这个问题我以为是我的jdk没有设置为1.8,但是在File >> Project Structure >> Project language level确实是8。

error

确认了依然是:Try-with-resources are not supported at language level '5’错误。

后来更改pom.xml 中添加以下配置就好了:

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

出现该错误的原因是我的maven没有指定jdk版本,在pom.xml中指定上就好。

Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐