现在我想使用jdk 11编译我的项目,我已经将默认java设置为java 11:
~/.m2 ⌚ 15:27:30
$ java -version ‹ruby-2.7.2›
openjdk version "11.0.10" 2021-01-19
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.10+9)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.10+9, mixed mode)
(base)
并在中添加配置 ~/.m2/settings.xml
文件:
<profile>
<id>jdk-11</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>11</jdk>
</activation>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.compilerVersion>11</maven.compiler.compilerVersion>
</properties>
</profile>
但当我使用此命令编译项目时:
/usr/local/Cellar/maven@3.5/3.5.4_1/bin/mvn install
显示错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project util: Compilation failure: Compilation failure:
[ERROR] /Users/dolphin/source/dj/source/backend/scom-java-common/util/src/main/java/scom/java/common/mulitshed/ShedTask.java:[5,14] illegal reference to restricted type 'var'
[ERROR] /Users/dolphin/source/dj/source/backend/scom-java-common/util/src/main/java/scom/java/common/mulitshed/RedisLocker.java:[5,14] illegal reference to restricted type 'var'
[ERROR] /Users/dolphin/source/dj/source/backend/scom-java-common/util/src/main/java/scom/java/common/controller/MysqlCheckControllerTester.java:[5,14] illegal reference to restricted type 'var'
[ERROR] /Users/dolphin/source/dj/source/backend/scom-java-common/util/src/main/java/scom/java/common/ntest/NTestService.java:[5,14] illegal reference to restricted type 'var'
我应该怎么做来解决这个问题?
1条答案
按热度按时间67up9zun1#
添加此配置: