jfinal升级jdk到jdk17后运行报错,如何解决?

报错日志如下:

java.lang.IllegalArgumentException: Unsupported class file major version 61

at net.sf.cglib.asm.$ClassReader.<init>(ClassReader.java:195)

at net.sf.cglib.asm.$ClassReader.<init>(ClassReader.java:176)

at net.sf.cglib.asm.$ClassReader.<init>(ClassReader.java:162)

at net.sf.cglib.asm.$ClassReader.<init>(ClassReader.java:283)

at net.sf.cglib.core.DuplicatesPredicate.<init>(DuplicatesPredicate.java:93)

at net.sf.cglib.proxy.Enhancer.getMethods(Enhancer.java:557)

at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:575)

at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)

at net.sf.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:332)

at net.sf.cglib.proxy.Enhancer.generate(Enhancer.java:492)

at net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:96)

at net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:94)

at net.sf.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54)

at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)

at net.sf.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61)

at net.sf.cglib.core.internal.LoadingCache.get(LoadingCache.java:34)

at net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:119)

at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:294)

at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:480)

at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:305)

at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:851)

at com.jfinal.ext.proxy.CglibProxyFactory.get(CglibProxyFactory.java:39)

at com.jfinal.proxy.Proxy.get(Proxy.java:32)

at com.jfinal.aop.AopFactory.createObject(AopFactory.java:181)

at com.jfinal.aop.AopFactory.doGetSingleton(AopFactory.java:91)

at com.jfinal.aop.AopFactory.doGet(AopFactory.java:65)

at com.jfinal.aop.AopFactory.get(AopFactory.java:48)

at com.jfinal.aop.Aop.get(Aop.jav


评论区

杜福忠

2024-08-21 11:31

看异常:
Unsupported class file major version 61 》不支持的类文件主版本 61。
at net.sf.cglib.asm 》 cglib AOP动态代理那个 jar。
文档:https://jfinal.com/doc/4-8

“升级jdk到jdk17后运行报错” 意思是之前 Java8 是正常的呗?
那就升级cglib依赖版本试试呗:
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>3.3.0</version>
</dependency>

JDK 17现在是建议是使用javassist代理, 使用:
public void configConstant(Constants me) {
me.setToJavassistProxyFactory();//改配置
}
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.29.2-GA</version>
</dependency>

热门反馈

扫码入社