2016-08-31 10 views
-5

根本原因例外:org.springframework.beans.factory.BeanCreationException

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'menuController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.tiles.dao.RegisterDao com.tiles.controllers.MenuController.redao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redao': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: javax.sql.DataSource com.tiles.dao.RegisterDao.dataSource; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ds' defined in ServletContext resource [/WEB-INF/spring-servlet.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are: 
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClassName' threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC driver class [com.mysql.jdbc.Driver] 
    org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:286) 
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1055) 
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511) 
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450) 
    org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290) 
    org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) 
    org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287) 
    org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189) 
    org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:562) 
    org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871) 
    org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423) 
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:443) 
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:459) 
    org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:340) 
    org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:307) 
    org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127) 
    javax.servlet.GenericServlet.init(GenericServlet.java:158) 
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) 
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) 
    org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616) 
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:521) 
    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1096) 
    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:674) 
    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:277) 
    java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) 
    java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 
    java.lang.Thread.run(Unknown Source) 
root cause 

org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.tiles.dao.RegisterDao com.tiles.controllers.MenuController.redao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redao': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: javax.sql.DataSource com.tiles.dao.RegisterDao.dataSource; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ds' defined in ServletContext resource [/WEB-INF/spring-servlet.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are: 
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClassName' threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC driver class [com.mysql.jdbc.Driver] 
    org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:507) 
    org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84) 
    org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:283) 
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1055) 
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511) 
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450) 
    org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290) 
    org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) 
    org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287) 
    org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189) 
    org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:562) 
    org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871) 
    org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423) 
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:443) 
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:459) 
    org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:340) 
    org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:307) 
    org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127) 
    javax.servlet.GenericServlet.init(GenericServlet.java:158) 
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) 
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) 
    org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616) 
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:521) 
    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1096) 
    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:674) 
    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:277) 
    java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) 
    java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 
    java.lang.Thread.run(Unknown Source) 
+1

すべてのJARSの適切なクラスパスが設定されていますか?コードを追加する –

+0

MenuController.java –

答えて

0

プロパティ 'driverClassName' は例外を投げました。ネストされた例外はjava.lang.IllegalStateExceptionです:だからJDBCドライバクラス[はcom.mysql.jdbc.Driver]

をロードできませんでした、あなたはdriverClassNameためcom.mysql.jdbc.Driverを指定し、DataSource Bean定義を持っています。しかし!クラスパスにそのようなクラスはありません!

プロジェクトにmysql-connector-java依存関係を追加し、実行時クラスパスに正しく移動していることを確認してください。

関連する問題