esplise更新maven报错java.lang.UnsupportedClassVersionError: PR/Sort : Unsupported major.minor version 52

当点击maven进行更新(主要是war工程)时,有时会遇到下面异常:


原因:maven默认使用jdk1.5进行项目编译,而我们所需要的jar或者tomcat需要更高版本的jdk,也就是说maven默认的环境达不到项目要求。此处的原因是因为工作环境默认选择用jdk1.8(52.0)进行编译,而spring版本不支持1.8,所以出现错误

解决方法:

在maven仓库的配置文件(conf/setting.xml)中的profiles标签中添加jdk配置:

	<profile>    
    	<id>jdk-1.7</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>

若没有生效,则在profiles标签后添加

<activeProfiles>
    <activeProfile>jdk-1.8</activeProfile><!--对应配置文件id-->
  </activeProfiles>

对其进行激活。此配置与私服配置相似。将jdk版本默认为1.8之后再按如下重新选择setting.xml(一定要重新选,不然更改不会对其生效):



重新加载maven成功后再更新项目,没有报错了。

参考:https://blog.csdn.net/qq_30908729/article/details/78802715

猜你喜欢

转载自blog.csdn.net/yinweicheng/article/details/80902381
今日推荐