1. 程式人生 > >com/alipay/api/AlipayApiException : Unsupported major.minor version 52.0

com/alipay/api/AlipayApiException : Unsupported major.minor version 52.0

異常:

java.lang.UnsupportedClassVersionError: com/alipay/api/AlipayApiException : Unsupported major.minor version 52.0

at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2625)
at java.lang.Class.getMethod0(Class.java:2866)
at java.lang.Class.getMethod(Class.java:1676)
at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)

at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)

原因:

本地jdk版本太低,不支援這個jdk1.8編譯過的專案執行。

解決方案:

01)換用較低版本的jar或依賴

02)Windows—— Preferences——Java——Compiler——設為jdk1.8

               在此頁面的Java——Installed JREs——設為jdk1.8

     專案右鍵——Build Path(也可是Properties)——Configure Build Path——Java Build Path——Libraries下面的JRE System Library改為jdk1.8

本人:

將  

   <!-- https://mvnrepository.com/artifact/net.guerlab/sdk-alipay-core -->
<dependency>
    <groupId>net.guerlab</groupId>
    <artifactId>sdk-alipay-core</artifactId>
    <version>1.2.0</version>
</dependency>
換成
<!-- https://mvnrepository.com/artifact/com.github.1991wangliang/alipay-sdk -->
	    <dependency>
	        <groupId>com.github.1991wangliang</groupId>
	        <artifactId>alipay-sdk</artifactId>
	        <version>1.0.0</version>
	    </dependency>

問題就解決了~~