1.往pom.xml配置maven-compiler-plugin依赖,声明jdk版本,再update project...即可。

<build>
  	<plugins>
  		<plugin>
  			<groupId>org.apache.maven.plugins</groupId>
  			<artifactId>maven-compiler-plugin</artifactId>
  			<version>3.8.0</version>
  			<configuration>
  			    <source>1.8</source>
  			    <target>1.8</target>
  			</configuration>
  		</plugin>
  	</plugins>
  </build>

2.修改maven的默认jdk配置,找到maven的conf\setting.xml(maven库所在)文件中找到jdk配置的地方。

<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>

 

添加完后,在对eclipse进行设置。window->preferences->maven->user settings,user settings那里选择maven安装目录下的settings.xml文件。如下图

eclipse中maven项目要update project...时,jdk的版本一直变为1.6

修改箭头所指的位置,去此路径下修改此文件,然后保存。最后再update project即可。

 

相关文章:

  • 2021-12-05
  • 2022-02-16
  • 2021-09-15
  • 2022-01-07
  • 2021-08-04
  • 2021-06-22
猜你喜欢
  • 2022-01-07
  • 2021-10-14
  • 2021-10-30
  • 2022-12-23
  • 2021-09-01
  • 2021-08-19
相关资源
相似解决方案