欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Spring Boot2深入分析解決java.lang.ArrayStoreException異常

 更新時(shí)間:2021年12月24日 15:44:40   作者:誰(shuí)將新樽辭舊月,今月曾經(jīng)照古人  
這篇文章介紹了Spring Boot2深入分析解決java.lang.ArrayStoreException異常的方法,對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧

將某個(gè)項(xiàng)目從Spring Boot1升級(jí)Spring Boot2之后出現(xiàn)如下報(bào)錯(cuò),查了很多不同的解決方法都沒(méi)有解決:

Spring boot2項(xiàng)目啟動(dòng)時(shí)遇到了異常:

java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy

Caused by: java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
    at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:724) ~[na:1.8.0_65]
    at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:531) ~[na:1.8.0_65]
    at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:355) ~[na:1.8.0_65]
    at sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:286) ~[na:1.8.0_65]
    at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:120) ~[na:1.8.0_65]
    at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:72) ~[na:1.8.0_65]
    at java.lang.Class.createAnnotationData(Class.java:3521) ~[na:1.8.0_65]
    at java.lang.Class.annotationData(Class.java:3510) ~[na:1.8.0_65]
    at java.lang.Class.createAnnotationData(Class.java:3526) ~[na:1.8.0_65]
    at java.lang.Class.annotationData(Class.java:3510) ~[na:1.8.0_65]
    at java.lang.Class.getAnnotation(Class.java:3415) ~[na:1.8.0_65]
    at java.lang.reflect.AnnotatedElement.isAnnotationPresent(AnnotatedElement.java:258) ~[na:1.8.0_65]
    at java.lang.Class.isAnnotationPresent(Class.java:3425) ~[na:1.8.0_65]
    at org.springframework.core.annotation.AnnotatedElementUtils.hasAnnotation(AnnotatedElementUtils.java:570) ~[spring-core-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.isHandler(RequestMappingHandlerMapping.java:177) ~[spring-webmvc-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.initHandlerMethods(AbstractHandlerMethodMapping.java:218) ~[spring-webmvc-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.afterPropertiesSet(AbstractHandlerMethodMapping.java:189) ~[spring-webmvc-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.afterPropertiesSet(RequestMappingHandlerMapping.java:136) ~[spring-webmvc-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1758) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1695) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    ... 16 common frames omitted

經(jīng)過(guò)簡(jiǎn)單排查后,懷疑是因?yàn)閖ar版本沖突引起的異常,使用異常斷點(diǎn):

然后在

應(yīng)該是從class org.activiti.spring.boot.SecurityAutoConfiguration出錯(cuò),然后報(bào)錯(cuò)java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy

嘗試復(fù)現(xiàn)異常:

SecurityAutoConfiguration securityAutoConfiguration=new SecurityAutoConfiguration();

正常

SecurityAutoConfiguration.class.getDeclaredAnnotation(Aspect.class);

異常復(fù)現(xiàn)。

然后找到TypeNotPresentExceptionProxy類,使用Ctrl+N/Ctrl+N+N

然后在構(gòu)造方法中打斷點(diǎn),發(fā)現(xiàn):

發(fā)現(xiàn)是cause:DefaultAuthenticationEventPublisher找不到引發(fā)的報(bào)錯(cuò)。

實(shí)際報(bào)錯(cuò)是ClassNotFound。

仔細(xì)看下代碼,可以發(fā)現(xiàn)AnnotationParser.parseClassValue把異常包裝成為Object。

private static Object parseClassValue(ByteBuffer buf,
                                          ConstantPool constPool,
                                          Class<?> container) {
        int classIndex = buf.getShort() & 0xFFFF;
        try {
            try {
                String sig = constPool.getUTF8At(classIndex);
                return parseSig(sig, container);
            } catch (IllegalArgumentException ex) {
                // support obsolete early jsr175 format class files
                return constPool.getClassAt(classIndex);
            }
        } catch (NoClassDefFoundError e) {
            return new TypeNotPresentExceptionProxy("[unknown]", e);
        }
        catch (TypeNotPresentException e) {
            return new TypeNotPresentExceptionProxy(e.typeName(), e.getCause());
        }
    }

然后在sun.reflect.annotation.AnnotationParser.parseClassArray(int, ByteBuffer, ConstantPool, Class<?>)里嘗試直接設(shè)置到數(shù)組里。

而這里數(shù)組越界了,ArrayStoreException只有越界的Object的類型信息,也就是上面的。

解決:

  • 1:將springboot2.0降級(jí)為原來(lái)的1.X版本
  • 2:在springboot啟動(dòng)類上添加
@SpringBootApplication(exclude = SecurityAutoConfiguration.class)
  • 3:修改源碼的集成問(wèn)題,重新編譯

總結(jié):

具體問(wèn)題還要具體分析,不同的代碼引發(fā)該問(wèn)題的原因也不相同。

我的問(wèn)題是:

springboot2.0不能與activiti6.0.0直接集成使用,因?yàn)閍ctiviti6.0.0出來(lái)的時(shí)候springboot2.0還沒(méi)有出來(lái),activiti6.0.0 支持springboot1.2.6以上,2.0.0以下的版本。

這里實(shí)際報(bào)錯(cuò)是ClassNotFound。

到此這篇關(guān)于Spring Boot2深入分析解決java.lang.ArrayStoreException異常的文章就介紹到這了。希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • MyBatis通用Mapper和PageHelper的過(guò)程詳解

    MyBatis通用Mapper和PageHelper的過(guò)程詳解

    這篇文章主要介紹了MyBatis通用Mapper和PageHelper的相關(guān)知識(shí),本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-11-11
  • spring boot整合RabbitMQ(Direct模式)

    spring boot整合RabbitMQ(Direct模式)

    springboot集成RabbitMQ非常簡(jiǎn)單,如果只是簡(jiǎn)單的使用配置非常少,springboot提供了spring-boot-starter-amqp項(xiàng)目對(duì)消息各種支持。下面通過(guò)本文給大家介紹下spring boot整合RabbitMQ(Direct模式),需要的朋友可以參考下
    2017-04-04
  • Java仿12306圖片驗(yàn)證碼

    Java仿12306圖片驗(yàn)證碼

    這篇文章主要為大家詳細(xì)介紹了Java仿12306的圖片驗(yàn)證碼的相關(guān)資料,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-04-04
  • Java面向接口編程之命令模式實(shí)例詳解

    Java面向接口編程之命令模式實(shí)例詳解

    這篇文章主要介紹了Java面向接口編程之命令模式,結(jié)合實(shí)例形式詳細(xì)分析了Java面向接口編程命令模式的定義、使用方法及相關(guān)操作注意事項(xiàng),需要的朋友可以參考下
    2019-09-09
  • Java SpringBoot自動(dòng)裝配原理詳解

    Java SpringBoot自動(dòng)裝配原理詳解

    這篇文章主要介紹了詳解Spring Boot自動(dòng)裝配的原理,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2021-09-09
  • 詳解一個(gè)簡(jiǎn)單的Servlet容器的設(shè)計(jì)與實(shí)現(xiàn)

    詳解一個(gè)簡(jiǎn)單的Servlet容器的設(shè)計(jì)與實(shí)現(xiàn)

    Servlet算是Java Web開(kāi)發(fā)請(qǐng)求鏈路調(diào)用棧中底層的一個(gè)技術(shù),而了解一個(gè)Servlet容器的實(shí)現(xiàn)有助于更好的理解JavaWeb開(kāi)發(fā),所以下面就來(lái)看看如何設(shè)計(jì)與實(shí)現(xiàn)一個(gè)簡(jiǎn)單的Servlet容器吧
    2023-07-07
  • springboot連接Redis的教程詳解

    springboot連接Redis的教程詳解

    這篇文章主要介紹了springboot連接Redis的教程詳解,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-03-03
  • FeignClient中name和url屬性的作用說(shuō)明

    FeignClient中name和url屬性的作用說(shuō)明

    這篇文章主要介紹了FeignClient中name和url屬性的作用說(shuō)明,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-06-06
  • 使用jpa的時(shí)候set實(shí)體類屬性自動(dòng)持久化的解決方案

    使用jpa的時(shí)候set實(shí)體類屬性自動(dòng)持久化的解決方案

    這篇文章主要介紹了使用jpa的時(shí)候set實(shí)體類屬性自動(dòng)持久化的解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2021-08-08
  • Java終止線程實(shí)例和stop()方法源碼閱讀

    Java終止線程實(shí)例和stop()方法源碼閱讀

    這篇文章主要介紹了Java終止線程實(shí)例和stop()方法源碼閱讀,具有一定借鑒價(jià)值,需要的朋友可以參考下
    2017-12-12

最新評(píng)論