org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerAdapter' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]: Factory method 'requestMappingHandlerAdapter' threw exception; nested exception is java.lang.NoClassDefFoundError: net/minidev/json/writer/JsonReader
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:656) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:636) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1338) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:879) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878) ~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.2.4.RELEASE.jar:2.2.4.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.2.4.RELEASE.jar:2.2.4.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.2.4.RELEASE.jar:2.2.4.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.2.4.RELEASE.jar:2.2.4.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.2.4.RELEASE.jar:2.2.4.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.2.4.RELEASE.jar:2.2.4.RELEASE]
	at com.cesiumai.autopilot.basic.BasicServerApplication.main(BasicServerApplication.java:20) [classes/:na]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]: Factory method 'requestMappingHandlerAdapter' threw exception; nested exception is java.lang.NoClassDefFoundError: net/minidev/json/writer/JsonReader
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:651) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	... 19 common frames omitted
Caused by: java.lang.NoClassDefFoundError: net/minidev/json/writer/JsonReader
	at com.jayway.jsonpath.spi.mapper.JsonSmartMappingProvider.<clinit>(JsonSmartMappingProvider.java:32) ~[json-path-2.4.0.jar:2.4.0]
	at com.jayway.jsonpath.internal.DefaultsImpl.<init>(DefaultsImpl.java:17) ~[json-path-2.4.0.jar:2.4.0]
	at com.jayway.jsonpath.internal.DefaultsImpl.<clinit>(DefaultsImpl.java:15) ~[json-path-2.4.0.jar:2.4.0]
	at com.jayway.jsonpath.Configuration.getEffectiveDefaults(Configuration.java:48) ~[json-path-2.4.0.jar:2.4.0]
	at com.jayway.jsonpath.Configuration.access$000(Configuration.java:34) ~[json-path-2.4.0.jar:2.4.0]
	at com.jayway.jsonpath.Configuration$ConfigurationBuilder.build(Configuration.java:229) ~[json-path-2.4.0.jar:2.4.0]
	at org.springframework.data.web.JsonProjectingMethodInterceptorFactory.<init>(JsonProjectingMethodInterceptorFactory.java:75) ~[spring-data-commons-2.2.4.RELEASE.jar:2.2.4.RELEASE]
	at org.springframework.data.web.ProjectingJackson2HttpMessageConverter.initProjectionFactory(ProjectingJackson2HttpMessageConverter.java:87) ~[spring-data-commons-2.2.4.RELEASE.jar:2.2.4.RELEASE]
	at org.springframework.data.web.ProjectingJackson2HttpMessageConverter.<init>(ProjectingJackson2HttpMessageConverter.java:72) ~[spring-data-commons-2.2.4.RELEASE.jar:2.2.4.RELEASE]
	at org.springframework.data.web.config.SpringDataWebConfiguration.extendMessageConverters(SpringDataWebConfiguration.java:163) ~[spring-data-commons-2.2.4.RELEASE.jar:2.2.4.RELEASE]
	at org.springframework.web.servlet.config.annotation.WebMvcConfigurerComposite.extendMessageConverters(WebMvcConfigurerComposite.java:144) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration.extendMessageConverters(DelegatingWebMvcConfiguration.java:123) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport.getMessageConverters(WebMvcConfigurationSupport.java:812) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport.requestMappingHandlerAdapter(WebMvcConfigurationSupport.java:614) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	at org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration.requestMappingHandlerAdapter(WebMvcAutoConfiguration.java:369) ~[spring-boot-autoconfigure-2.2.4.RELEASE.jar:2.2.4.RELEASE]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_72]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_72]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_72]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_72]
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
	... 20 common frames omitted
Caused by: java.lang.ClassNotFoundException: net.minidev.json.writer.JsonReader
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_72]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_72]
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_72]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_72]
	... 40 common frames omitted
Disconnected from the target VM, address: '127.0.0.1:55186', transport: 'socket'

NoClassDefFoundError错误发生的原因

NoClassDefFoundError错误的发生,是因为Java虚拟机在编译时能找到合适的类,而在运行时不能找到合适的类导致的错误。例如在运行时我们想调用某个类的方法或者访问这个类的静态成员的时候,发现这个类不可用,此时Java虚拟机就会抛出NoClassDefFoundError错误。与ClassNotFoundException的不同在于,这个错误发生只在运行时需要加载对应的类不成功,而不是编译时发生。很多Java开发者很容易在这里把这两个错误搞混。

简单总结就是,NoClassDefFoundError发生在编译时对应的类可用,而运行时在Java的classpath路径中,对应的类不可用导致的错误。
解决上诉异常的办法
在这里插入图片描述
找到相应模块报错的jar包,调整范围,之前是test,结合异常发生原因,改成了Runtime。点击apply 然后OK就行了。
在这里插入图片描述如果没能解决,建议去搜索NoClassDefFoundError相关帖子。

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerAdapter' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet...
java.lang.NoClassDefFoundError: javax/validation/valueextraction/ValueExtractorDeclarationException  今天部署环境遇到这个问题,查了好长时间终于解决了; 问题原因: 由于jar包hibernate-validator、validation-api 不兼容。 解决方案: (1). 简单粗暴:根据需求删除不兼容的jar包,删除jar包必须在保证代码没有使用的情况下,不知道的尽量别删除; (2).解决兼容问题: 版本不兼容,就找兼容版本。  升级hibernate-validator版本: &lt;dependency&gt; &lt;groupId&gt;net.minidev&lt;/groupId&gt; &lt;artifactId&gt;asm&lt;/artifactId&gt; &lt...
这几天在完成学校作业的时候,需要使用处理 json 的返回值格式,在引入了 json-lib-2.4 后发现报错, java.lang.NoClassDefFoundError ,这是因为没有引入其他 5 个相关的依赖包。 在网上单独下载这几个包很麻烦,这里贴一个网址,里面免费提供了这几个相关包。 org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpClient Caused by: java.lang.ClassNotFoundException: org.apac
2.发现已经全部导入所需要的包了,还是出现该问题。经检查发现,这些包是我在tomcat部署项目之后才引入的。myeclipse不会自动将这些包部署到tomcat,所以重新部署一下项目就可以了。 3.还有些同学提到可能与自带的JSON冲突的
这个错误通常是由于你使用的Jedis版本过低所导致的。GeoUnit是Jedis 3.0.0版本新增的一个类,如果你使用的是Jedis 2.x版本,就会出现NoClassDefFoundError异常。 你可以尝试升级Jedis版本,或者在使用Jedis 2.x版本时避免使用GeoUnit类。如果你需要使用GeoUnit类提供的功能,可以在pom.xml文件中添加以下Maven依赖库来升级Jedis版本: <dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> <version>3.0.0</version> </dependency> 如果你不是使用Maven构建的项目,可以手动下载Jedis库并添加到你的项目中。
Cause: org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping
Cause: org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping qq_37970469: 补充:sql语句出错也会报这个错误,留意数据有没有加在双引号内 深刻理解JAVA中i++和++i的区别 流水叮叮: 能解释第二题吗?为啥a的值为9而不是10 EasyCode代码生成器,超详细安装和生成模板 echofzoe: 数据库字段名用下划线隔开,对应实体类里的驼峰命名,比如 book_id ---> bookId EasyCode代码生成器,超详细安装和生成模板 燃烧的鸡胸肉: EasyCode可以使用驼峰命名法吗?调了好久模板没弄好。