The problem of Maven project generation or update jdk becoming 1.5

When using Maven to build the project, the generated maven project jdk uses jdk1.5 by default.

After manually modifying the jdk, the jdk will become 1.5 again after the update project.

Or generated with eclipse's Maven plugin is also 1.5

There are two ways for this situation, one is to modify settings.xml, the other is to modify the pom file

1. Configure settings.xml

 

Open the settings.xml file and edit it (usually in your repository directory):
(If you don't know, see my article: Introduction to Maven, Installation, Configuration )
<profile>    
    <id>jdk-1.8</id>    
    <activation>    
        <activeByDefault>true</activeByDefault>    
        <jdk>1.8</jdk>    
    </activation>    
    <properties>    
        <maven.compiler.source>1.8</maven.compiler.source>    
        <maven.compiler.target>1.8</maven.compiler.target>    
        <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>    
    </properties>    
</profile> 
Find the <profiles> node, and add the above configuration (native jdk 1.8.0—25 version, modify it to your native jdk version during configuration), and save it to take effect.

 

Modify the settings in Eclipse to make the configuration take effect.

2. Configure the pom.xml file

 

Add the following configuration to the <build> node (the local jdk 1.7.0_79 version, modify the configuration to your local jdk version):
<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <configuration>
        <source>1.7</source>
        <target>1.7</target>
      </configuration>
    </plugin>
  </plugins>
</build>
After the configuration is complete, you need to perform an action to update the project configuration. Select the project --> Right click --> Maven --> Update Project
 
The first method is effective globally, and the second method is only effective for this project.

 Reprinted from: https://blog.csdn.net/sinat_32873711/article/details/53784618

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325118417&siteId=291194637