Loading

Error:unsupported class file version 52.0问题的解决

     这个问题主要的原因是依赖包的编译版本比主程序的编译版本高,导致主程序无法正常编译或运行,解决这个问题无非两招:

     1、提升主程序的编译器版本,用最新的编译器编译主程序,这样就可以兼容那个依赖包

     2、降低依赖包的编译版本。比如maven,降低到1.6的方法是:

 

  1. <plugin>   
  2.   <groupId>org.apache.maven.plugins</groupId>   
  3.   <artifactId>maven-compiler-plugin</artifactId>  
  4.   <version>3.1</version>   
  5.   <configuration>   
  6.       <source>1.6</source>   
  7.       <target>1.6</target>   
  8.       <encoding>UTF8</encoding>   
  9.   </configuration>   
  10. </plugin>   

另附打本地依赖包的配置:

 

  1. <build>  
  2.         <sourceDirectory>src/main/java</sourceDirectory>  
  3.         <plugins>  
  4.             <plugin>  
  5.                 <groupId>org.apache.maven.plugins</groupId>  
  6.                 <artifactId>maven-compiler-plugin</artifactId>  
  7.                 <configuration>  
  8.                     <defaultLibBundleDir>lib</defaultLibBundleDir>  
  9.                     <source>1.5</source>  
  10.                     <target>1.5</target>  
  11.                     <encoding>UTF-8</encoding>  
  12.                 </configuration>  
  13.             </plugin>  
  14.             <plugin>  
  15.                 <groupId>org.apache.maven.plugins</groupId>  
  16.                 <artifactId>maven-jar-plugin</artifactId>  
  17.                 <configuration>  
  18.                     <archive>  
  19.                         <manifest>  
  20.                             <addClasspath>true</addClasspath>  
  21.                             <classpathPrefix></classpathPrefix>  
  22.                             <mainClass>com.xx.xx.xx</mainClass>  
  23.                         </manifest>  
  24.                     </archive>  
  25.                 </configuration>  
  26.             </plugin>  
  27.             <plugin>  
  28.                 <groupId>org.apache.maven.plugins</groupId>  
  29.                 <artifactId>maven-dependency-plugin</artifactId>  
  30.                 <executions>  
  31.                     <execution>  
  32.                         <id>copy</id>  
  33.                         <phase>install</phase>  
  34.                         <goals>  
  35.                             <goal>copy-dependencies</goal>  
  36.                         </goals>  
  37.                         <configuration>  
  38.                             <outputDirectory>  
  39.                                 ${project.build.directory}  
  40.                             </outputDirectory>  
  41.                         </configuration>  
  42.                     </execution>  
  43.                 </executions>  
  44.             </plugin>  
  45.             <plugin>  
  46.                 <groupId>org.apache.maven.plugins</groupId>  
  47.                 <artifactId>maven-resources-plugin</artifactId>  
  48.                 <version>2.2</version>  
  49.                 <configuration>  
  50.                     <encoding>UTF-8</encoding>  
  51.                 </configuration>  
  52.             </plugin>  
  53.         </plugins>  
  54.     </build>  


 

 
 
posted @ 2017-07-06 10:07  _朝晖  阅读(3644)  评论(0编辑  收藏  举报