找到maven的settings.xml配置文件:
打开settings.xml文件,找到profiles标签,加入以下代码:
<profile>
<id>jdk-17</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>17</jdk>
</activation>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
</profile>
<!-- jdk自行选择--!>
我也按照上述步骤修改settings.xml文件之后,发现并没有什么用,还是出错。然后之前一直都是用的记事本打开settings.xml文件,又都是一样的颜色,看着晕晕的,最终下了一个Sublime Text,打开settings.xml文件发现有提示的错误,尝试删除之后重启就不出错了。