Modification method of Update Maven JDK version change

The reason for the change of the JDK version of the Maven project:

1. The JDK version of a new Maven project does not correspond to the system version. 2. Right-click the Maven project -> Maven -> Update Project The JDK version has changed, 3. The operating system's JDK has been reinstalled with a new version, which is the cause of the first two phenomena main reason.

Modification method (if the system jdk version is 1.8):

Method 1: Specify the jdk version in the pom.xml file:

 

[html]  view plain copy  
 
 print ?
  1. <build>  
  2.         <plugins>  
  3.             <plugin>  
  4.                 <groupId>org.apache.maven.plugins</groupId>  
  5.                 <artifactId>maven-compiler-plugin</artifactId>  
  6.                 <version>3.1</version>  
  7.                 <configuration>  
  8.                     <source>1.8</source>  
  9.                     <target>1.8</target>  
  10.                 </configuration>  
  11.             </plugin>  
  12.         </plugins>  
  13.     </build>  


Method 2: Modify settings.xml, find the profiles node, and add in it

 

 

[html]  view plain copy  
 
 print ?
  1. <profile>    
  2.     <id>jdk-1.8</id>    
  3.      <activation>    
  4.           <activeByDefault>true</activeByDefault>    
  5.           <jdk>1.8</jdk>    
  6.       </activation>    
  7. <properties>    
  8. <maven.compiler.source>1.8</maven.compiler.source>    
  9. <maven.compiler.target>1.8</maven.compiler.target>    
  10. <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>    
  11. </properties>    
  12. </profile>  

Then the update project can be kept consistent with the system jdk version. It is recommended to use the second method to reduce the configuration of each project.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326778879&siteId=291194637
Recommended