BeanUtil.copy单测报异常

Blade 未结 1 775
beelzebub
beelzebub 2022-05-29 13:00
悬赏:10

junit4进行单测的时候

Objects.requireNonNull(BeanUtil.copy(template, Template.class))

报异常。堆栈如下:

java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "cause" is null


at org.springframework.cglib.core.CodeGenerationException.(CodeGenerationException.java:25)

at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:567)

at org.springframework.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:363)

at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:110)

at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:108)

at org.springframework.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54)

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

at org.springframework.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61)

at org.springframework.cglib.core.internal.LoadingCache.get(LoadingCache.java:34)

at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:134)

at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:319)

at org.springblade.core.tool.beans.BladeBeanCopier$Generator.create(BladeBeanCopier.java:138)

at org.springblade.core.tool.beans.BladeBeanCopier.lambda$create$0(BladeBeanCopier.java:79)

at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)

at org.springblade.core.tool.beans.BladeBeanCopier.create(BladeBeanCopier.java:73)

at org.springblade.core.tool.beans.BladeBeanCopier.create(BladeBeanCopier.java:67)

at org.springblade.core.tool.utils.BeanUtil.copy(BeanUtil.java:154)

at org.springblade.core.tool.utils.BeanUtil.copy(BeanUtil.java:133)


1条回答
  •  yinyuncan
    yinyuncan (楼主)
    2022-05-30 08:19


    spring的issyes这里给出的答案就是升级spring版本到5.3.12

    人家是jdk17才引发这个问题的 不知道你的jdk版本是多少

    https://github.com/spring-projects/spring-framework/issues/27490

    0 讨论(0)
提交回复