After the Maven project modifies the pom.xml file, Java compilation error: does not support release version XX

After the code is written and run, the compilation error is reported. Insert picture description here
Check the complier version and the target version of the project structure, both are 5. Every time the pom file is changed, the 1.5 version Insert picture description here
problem lies in the configuration of the Maven project. Find the file settings.xml and modify it ( If not, create a new file manually, named settings.xml)
To find the path of this configuration file, you can check settings/build/Build Tools/Maven
Insert picture description here
According to the path, it looks like this
Insert picture description here
Open settings.xml for editing, if not, create a new one!!!
Insert picture description here

Under the root path of profiles, add according to the desired java version, here is the jdk9 version,
save the file to take effect

        <profile>
            <id>jdk-1.9</id>
            <activation>
                <activeByDefault>true</activeByDefault>
                <jdk>1.9</jdk>
            </activation>
            <properties>
                <maven.compiler.source>1.9</maven.compiler.source>
                <maven.compiler.target>1.9</maven.compiler.target>
                <maven.compiler.compilerVersion>1.9</maven.compiler.compilerVersion>
            </properties>
        </profile>

My configuration:

<?xml version="1.0" encoding="UTF-8"?>

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <!-- 依据路径不同进行配置repository  -->
  <localRepository>C:\Users\悠一木碧\.m2\repository</localRepository>
  
  <interactiveMode>true</interactiveMode>
  <offline>false</offline>

  <pluginGroups>
  </pluginGroups>

  <proxies>
  </proxies>

  <servers>
  </servers>

  <mirrors>
    <!--配置阿里云maven私有仓库(即配阿里私服)-->
    <mirror>
      <id>alimaven</id>
      <mirrorOf>*</mirrorOf>
      <url>https://maven.aliyun.com/repository/central</url>
    </mirror>
  </mirrors>

    <profiles>
        <profile>
            <id>jdk-1.9</id>
            <activation>
                <activeByDefault>true</activeByDefault>
                <jdk>1.9</jdk>
            </activation>
            <properties>
                <maven.compiler.source>1.9</maven.compiler.source>
                <maven.compiler.target>1.9</maven.compiler.target>
                <maven.compiler.compilerVersion>1.9</maven.compiler.compilerVersion>
            </properties>
        </profile>
    </profiles>
  
</settings>

As shown, it has taken effect
Insert picture description here

Guess you like

Origin blog.csdn.net/Valishment/article/details/107359895