zoukankan      html  css  js  c++  java
  • 严重: StandardWrapper.Throwable

    1、错误描述

    严重: StandardWrapper.Throwable
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'exportController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private report.service.ExportService report.controller.ExportController.exportService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [report.service.ExportService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:292)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
    	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
    	at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:658)
    	at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:624)
    	at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:672)
    	at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:543)
    	at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:484)
    	at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
    	at javax.servlet.GenericServlet.init(GenericServlet.java:158)
    	at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1284)
    	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1197)
    	at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087)
    	at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5229)
    	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5516)
    	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
    	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    	at java.lang.Thread.run(Thread.java:745)
    Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private report.service.ExportService report.controller.ExportController.exportService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [report.service.ExportService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:508)
    	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289)
    	... 29 more
    Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [report.service.ExportService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1103)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:963)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:858)
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480)
    	... 31 more
    
    十一月 04, 2015 6:29:33 下午 org.apache.catalina.core.StandardContext loadOnStartup
    严重: Servlet /dop threw load() exception
    org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [report.service.ExportService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1103)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:963)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:858)
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480)
    	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
    	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
    	at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:658)
    	at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:624)
    	at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:672)
    	at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:543)
    	at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:484)
    	at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
    	at javax.servlet.GenericServlet.init(GenericServlet.java:158)
    	at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1284)
    	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1197)
    	at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087)
    	at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5229)
    	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5516)
    	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
    	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    	at java.lang.Thread.run(Thread.java:745)

    2、错误原因

    public interface UserDao
    {
           public List<User> findAll();
    }
    
    @Repository
    public class UserDaoImpl implements UserDao
    {
           @Override
           public List<User> findAll()
           {
                 return null;
           }
    }
    
    public interface UserService
    {
           public List<User> findAll();
    }
    
    public class UserServiceImpl implements UserService
    {
          @Autowired
          private UserDao userDao;
    
          @Override
          public List<User> findAll()
          {
                 return userDao.findAll();
          }
    }
    
    @Controller
    @RequestMapping("/user")
    public class UserController
    {
          @Autowired
          private UserService userService;
    
          @RequestMapping(value = "findAll")
          public void findAll() 
          {
    	userService.findAll();
          }
    }

         导致这个错误的原因是Service实现缺少@Service


    3、解决办法

    public interface UserDao
    {
           public List<User> findAll();
    }
    
    @Repository
    public class UserDaoImpl implements UserDao
    {
           @Override
           public List<User> findAll()
           {
                 return null;
           }
    }
    
    public interface UserService
    {
           public List<User> findAll();
    }
    
    @Service
    public class UserServiceImpl implements UserService
    {
          @Autowired
          private UserDao userDao;
    
          @Override
          public List<User> findAll()
          {
                 return userDao.findAll();
          }
    }
    
    @Controller
    @RequestMapping("/user")
    public class UserController
    {
          @Autowired
          private UserService userService;
    
          @RequestMapping(value = "findAll")
          public void findAll() 
          {
    	userService.findAll();
          }
    }


  • 相关阅读:
    Flask使用mysql数据池
    Flask之WTForms
    Flask用Flask-SQLAlchemy连接MySQL
    Flask之中间件
    Flask之session相关
    Flask之请求和响应
    Flask路由系统与模板系统
    Flask之基本使用与配置
    Flask知识总汇
    Flask之视图函数
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13314333.html
Copyright © 2011-2022 走看看