0


使用 Postman 工具以 json 的方式请求 /test 接口时报错

报错内容:

在这里插入图片描述

2024-02-1518:04:20.716ERROR18920---[           main]o.s.b.web.embedded.tomcat.TomcatStarter:Error starting Tomcatcontext. Exception:org.springframework.beans.factory.BeanCreationException. Message:Error creating bean withname 'formContentFilter' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.class]:Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException:Failedtoinstantiate[org.springframework.boot.web.servlet.filter.OrderedFormContentFilter]:Factory method 'formContentFilter' threw exception; nested exception is org.springframework.beans.BeanInstantiationException:Failedtoinstantiate[com.fasterxml.jackson.datatype.jsr310.JavaTimeModule]:Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ser/std/ToStringSerializerBase
2024-02-1518:04:20.747ERROR18920---[           main]o.s.boot.SpringApplication:Application run failed

详细报错信息

org.springframework.context.ApplicationContextException:Unabletostart web server; nested exception is org.springframework.boot.web.server.WebServerException:Unabletostart embedded Tomcat
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:163)~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:577)~[spring-context-5.3.15.jar:5.3.15]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732)[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:414)[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:302)[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303)[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292)[spring-boot-2.6.3.jar:2.6.3]
    at com.han.weblog.web.WeblogWebApplication.main(WeblogWebApplication.java:12)[classes/:na]Caused by:org.springframework.boot.web.server.WebServerException:Unabletostart embedded Tomcat
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:142)~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:104)~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:478)~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:211)~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:182)~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:160)~[spring-boot-2.6.3.jar:2.6.3]...8 common frames omitted
Caused by:org.springframework.beans.factory.BeanCreationException:Error creating bean withname 'formContentFilter' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.class]:Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException:Failedtoinstantiate[org.springframework.boot.web.servlet.filter.OrderedFormContentFilter]:Factory method 'formContentFilter' threw exception; nested exception is org.springframework.beans.BeanInstantiationException:Failedtoinstantiate[com.fasterxml.jackson.datatype.jsr310.JavaTimeModule]:Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ser/std/ToStringSerializerBase
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658)~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:486)~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352)~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195)~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213)~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:212)~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addAsRegistrationBean(ServletContextInitializerBeans.java:175)~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addAsRegistrationBean(ServletContextInitializerBeans.java:170)~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addAdaptableBeans(ServletContextInitializerBeans.java:155)~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.web.servlet.ServletContextInitializerBeans.<init>(ServletContextInitializerBeans.java:87)~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getServletContextInitializerBeans(ServletWebServerApplicationContext.java:260)~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.selfInitialize(ServletWebServerApplicationContext.java:234)~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.web.embedded.tomcat.TomcatStarter.onStartup(TomcatStarter.java:53)~[spring-boot-2.6.3.jar:2.6.3]
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5219)~[tomcat-embed-core-9.0.56.jar:9.0.56]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)~[tomcat-embed-core-9.0.56.jar:9.0.56]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396)~[tomcat-embed-core-9.0.56.jar:9.0.56]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386)~[tomcat-embed-core-9.0.56.jar:9.0.56]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)~[na:1.8.0_392]
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)~[tomcat-embed-core-9.0.56.jar:9.0.56]
    at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)~[na:1.8.0_392]
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919)~[tomcat-embed-core-9.0.56.jar:9.0.56]
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:835)~[tomcat-embed-core-9.0.56.jar:9.0.56]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)~[tomcat-embed-core-9.0.56.jar:9.0.56]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396)~[tomcat-embed-core-9.0.56.jar:9.0.56]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386)~[tomcat-embed-core-9.0.56.jar:9.0.56]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)~[na:1.8.0_392]
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)~[tomcat-embed-core-9.0.56.jar:9.0.56]
    at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)~[na:1.8.0_392]
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919)~[tomcat-embed-core-9.0.56.jar:9.0.56]
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:263)~[tomcat-embed-core-9.0.56.jar:9.0.56]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)~[tomcat-embed-core-9.0.56.jar:9.0.56]
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:432)~[tomcat-embed-core-9.0.56.jar:9.0.56]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)~[tomcat-embed-core-9.0.56.jar:9.0.56]
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:927)~[tomcat-embed-core-9.0.56.jar:9.0.56]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)~[tomcat-embed-core-9.0.56.jar:9.0.56]
    at org.apache.catalina.startup.Tomcat.start(Tomcat.java:486)~[tomcat-embed-core-9.0.56.jar:9.0.56]
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:123)~[spring-boot-2.6.3.jar:2.6.3]...13 common frames omitted
Caused by:org.springframework.beans.BeanInstantiationException:Failedtoinstantiate[org.springframework.boot.web.servlet.filter.OrderedFormContentFilter]:Factory method 'formContentFilter' threw exception; nested exception is org.springframework.beans.BeanInstantiationException:Failedtoinstantiate[com.fasterxml.jackson.datatype.jsr310.JavaTimeModule]:Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ser/std/ToStringSerializerBase
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)~[spring-beans-5.3.15.jar:5.3.15]...54 common frames omitted
Caused by:org.springframework.beans.BeanInstantiationException:Failedtoinstantiate[com.fasterxml.jackson.datatype.jsr310.JavaTimeModule]:Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ser/std/ToStringSerializerBase
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:224)~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:146)~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.registerWellKnownModulesIfAvailable(Jackson2ObjectMapperBuilder.java:832)~[spring-web-5.3.15.jar:5.3.15]
    at org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.configure(Jackson2ObjectMapperBuilder.java:691)~[spring-web-5.3.15.jar:5.3.15]
    at org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.build(Jackson2ObjectMapperBuilder.java:674)~[spring-web-5.3.15.jar:5.3.15]
    at org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.<init>(MappingJackson2HttpMessageConverter.java:59)~[spring-web-5.3.15.jar:5.3.15]
    at org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter.<init>(AllEncompassingFormHttpMessageConverter.java:91)~[spring-web-5.3.15.jar:5.3.15]
    at org.springframework.web.filter.FormContentFilter.<init>(FormContentFilter.java:61)~[spring-web-5.3.15.jar:5.3.15]
    at org.springframework.boot.web.servlet.filter.OrderedFormContentFilter.<init>(OrderedFormContentFilter.java:29)~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration.formContentFilter(WebMvcAutoConfiguration.java:179)~[spring-boot-autoconfigure-2.6.3.jar:2.6.3]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)~[na:1.8.0_392]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)~[na:1.8.0_392]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)~[na:1.8.0_392]
    at java.lang.reflect.Method.invoke(Method.java:498)~[na:1.8.0_392]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)~[spring-beans-5.3.15.jar:5.3.15]...55 common frames omitted
Caused by:java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ser/std/ToStringSerializerBase
    at com.fasterxml.jackson.datatype.jsr310.JavaTimeModule.<init>(JavaTimeModule.java:158)~[jackson-datatype-jsr310-2.13.1.jar:2.13.1]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(NativeMethod)~[na:1.8.0_392]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)~[na:1.8.0_392]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)~[na:1.8.0_392]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)~[na:1.8.0_392]
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:211)~[spring-beans-5.3.15.jar:5.3.15]...69 common frames omitted

Process finished withexit code 1

问题解决

更改父项目中的依赖版本

  • 更改前:在这里插入图片描述
  • 更改后:在这里插入图片描述
  • 运行测试在这里插入图片描述
  • 使用postman以json方式请求/test接口在这里插入图片描述
  • 控制台打印日志在这里插入图片描述

本文转载自: https://blog.csdn.net/2201_75344078/article/details/136122094
版权归原作者 yzkkdhh 所有, 如有侵权,请联系我们删除。

“使用 Postman 工具以 json 的方式请求 /test 接口时报错”的评论:

还没有评论