Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What if there is a java.lang.ArrayStoreException exception in the Springboot project?

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail what to do about java.lang.ArrayStoreException anomalies in Springboot projects. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

Using springboot 2 to build the project, the following error message appears when debugging the code

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invocation of init method failed Nested exception is java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean (AbstractAutowireCapableBeanFactory.java:1708) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean (AbstractAutowireCapableBeanFactory.java:581) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean (AbstractAutowireCapableBeanFactory.java:503) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0 (AbstractBeanFactory.java:317) at org.springframework.beans.factory.support. DefaultSingletonBeanRegistry.getSingleton (DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (AbstractBeanFactory.java:315) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:199) at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate (DependencyDescriptor.java:251) at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry (DefaultListableBeanFactory.java:1325) at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates (DefaultListableBeanFactory .java: 1291) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveMultipleBeans (DefaultListableBeanFactory.java:1193) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency (DefaultListableBeanFactory.java:1096) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency (DefaultListableBeanFactory.java:1065) at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument (ConstructorResolver.java:818) at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray (ConstructorResolver.java:724) ... 36 common frames omittedCaused by: java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy at sun.reflect.annotation.AnnotationParser.parseClassArray (AnnotationParser.java:724) at sun.reflect.annotation.AnnotationParser.parseArray (AnnotationParser.java:531) at sun.reflect.annotation.AnnotationParser.parseMemberValue (AnnotationParser.java:355) at sun.reflect.annotation.AnnotationParser.parseAnnotation2 (AnnotationParser.java:286) at sun.reflect.annotation.AnnotationParser.parseAnnotations2 (AnnotationParser.java:120) At sun.reflect.annotation.AnnotationParser.parseAnnotations (AnnotationParser.java:72) at java.lang.Class.createAnnotationData (Class.java:3521) at java.lang.Class.annotationData (Class.java:3510) at java.lang.Class.createAnnotationData (Class.java:3526) at java.lang.Class.annotationData (Class.java:3510) at java.lang.Class.getAnnotation (Class.java:3415) at java.lang.reflect.AnnotatedElement.isAnnotationPresent (AnnotatedElement.java:258 ) at java.lang.Class.isAnnotationPresent (Class.java:3425) at org.springframework.core.annotation.AnnotatedElementUtils.hasAnnotation (AnnotatedElementUtils.java:573) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.isHandler (RequestMappingHandlerMapping.java:177) at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.initHandlerMethods (AbstractHandlerMethodMapping.java:217) at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.afterPropertiesSet (AbstractHandlerMethodMapping.java:188) at org.springframework.web .servlet.mvc.method.annotation.RequestMappingHandlerMapping.roomPropertiesSet (RequestMappingHandlerMapping.java:129) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods (AbstractAutowireCapableBeanFactory.java:1767) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean (AbstractAutowireCapableBeanFactory.java:1704)... 50 common frames omitted

When I saw this problem at first glance, I felt that the head was relatively big, so I could only debug and determine, create a new breakpoint, the type is Java Exception Breakpoint, and the exception class is the java.lang.ArrayStoreException thrown above.

Through debugging, you can't find the class org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration, but AnnotationParser.parseClassValue wraps the exception as Object, and then in sun.reflect.annotation.AnnotationParser.parseClassArray (int, ByteBuffer, ConstantPool, Class)

Result [I] = parseClassValue (buf, constPool, container)

Here, the array is out of bounds, and ArrayStoreException only has the type information of the out-of-bounds Object, that is, the above

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

If it is found to be java.lang.ClassNotFoundException: org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration, then add the @ ConditionalOnClass check.

To be exact, spring boot2 changed the package of some classes:

The name of the class in spring boot 1 is:

Org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration

The name of the class in spring boot 2 is:

Org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration

And my solution is relatively simple and rough, subdivide the project, put some influential pom projects (activiti-spring-boot-starter-basic) into a new project, independent into a module to use.

This is the end of the article on "what to do if there is an java.lang.ArrayStoreException exception in the Springboot project". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report