请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

controller的测试报错

严重: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'areaServiceImpl' defined in file [C:\Program Files\Apache Software Foundation\Tomcat 8.5\wtpwebapps\o2o\WEB-INF\classes\com\imooc\o2o\service\impl\AreaServiceImpl.class]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect bean class [com.imooc.o2o.service.impl.AreaServiceImpl] for resource metadata: could not find class that it depends on
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:526)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
 at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
 at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)
 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
 at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668)
 at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634)
 at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682)
 at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553)
 at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494)
 at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:138)
 at javax.servlet.GenericServlet.init(GenericServlet.java:158)
 at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1132)
 at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1079)
 at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:763)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:134)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
 at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:660)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
 at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:798)
 at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
 at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:808)
 at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
 at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
 at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
 at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalStateException: Failed to introspect bean class [com.imooc.o2o.service.impl.AreaServiceImpl] for resource metadata: could not find class that it depends on
 at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.findResourceMetadata(CommonAnnotationBeanPostProcessor.java:344)
 at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(CommonAnnotationBeanPostProcessor.java:297)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:992)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:523)
 ... 35 more
Caused by: java.lang.NoClassDefFoundError: Lcom/imooc/o2o/dao/AreaDao;
 at java.lang.Class.getDeclaredFields0(Native Method)
 at java.lang.Class.privateGetDeclaredFields(Unknown Source)
 at java.lang.Class.getDeclaredFields(Unknown Source)
 at org.springframework.util.ReflectionUtils.getDeclaredFields(ReflectionUtils.java:715)
 at org.springframework.util.ReflectionUtils.doWithLocalFields(ReflectionUtils.java:656)
 at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.buildResourceMetadata(CommonAnnotationBeanPostProcessor.java:361)
 at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.findResourceMetadata(CommonAnnotationBeanPostProcessor.java:340)
 ... 38 more
Caused by: java.lang.ClassNotFoundException: com.imooc.o2o.dao.AreaDao
 at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1360)
 at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1182)
 ... 45 more

正在回答 回答被采纳积分+3

1回答

翔仔 2019-11-07 22:51:14

com.imooc.o2o.dao.AreaDao这个接口是不是没定义?错误报的是这个 请仔细检查


0 回复 有任何疑惑可以回复我~
  • 提问者 慕仔0506944 #1
    那个没有错,是pom.xml的配置出错了
    回复 有任何疑惑可以回复我~ 2019-11-08 14:18:49
  • 翔仔 回复 提问者 慕仔0506944 #2
    从异常信息确实是说当时的类加载器加载不到对已给你的AreaDao造成的,应该不会是pom.xml没有配置导致的异常,程序说1是1,不会骗人,所以可能是其他问题联动导致出现的这个问题,需要多总结
    回复 有任何疑惑可以回复我~ 2019-11-08 23:42:09
  • 提问者 慕仔0506944 回复 翔仔 #3
    但是我是在,重写pom.xml文件之后,报错就消失了,并且在之前的验证都是对的,那是不是可以说是,因为在service这层的配置没对,导致无法加载到AreaDao导致的
    回复 有任何疑惑可以回复我~ 2019-11-11 16:34:07
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信