controller的测试报错

来源:1-2 开发准备

慕仔0506944

2019-11-07

严重: 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

写回答

1回答

翔仔

2019-11-07

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


0
4
翔仔
回复
慕仔0506944
重写的时候跟之前是有什么不同呢?没引入spring相关的jar还是,同学光这样描述我也没办法具体定位问题呢,毕竟咱们环境不一样,同学提问的时候给个建议哈,应该把便于大家理解的信息给提供足,换位思考一下,这样对你后续工作很有帮助,光描述现象是没法具体定位问题的,我只能说根据经验应该是mapper配置不对,service层没有扫描到对应的Dao实现类造成的
2019-11-11
共4条回复

Java双版本(SSM到SpringBoot)校园商铺全栈开发

SSM商铺V1.0,解决毕设痛点;SpringBoot商铺V2.0,满足工作刚需

5113 学习 · 8144 问题

查看课程