严重:上下文初始化失败 org.springframework.beans.factory.BeanCreationException:创建名为' transactionManager'的bean时出错在ServletContext资源[/WEB-INF/springrest-servlet.xml]中定义:init方法的调用失败;嵌套异常是java.lang.NoClassDefFoundError:org / springframework / jdbc / datasource / TransactionAwareDataSourceProxy 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578) 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) at org.springframework.beans.factory.support.AbstractBeanFactory $ 1.getObject(AbstractBeanFactory.java:305) 在org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) 在org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301) 在org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772) 在org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:834) 在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537) 在org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:667) 在org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:633) 在org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:681) 在org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:552) 在org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:493) 在org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136) 在javax.servlet.GenericServlet.init(GenericServlet.java:158) 在org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1194) 在org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1110) 在org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1000) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4901) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5211) 在org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152) 在org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1403) 在org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1393) at java.util.concurrent.FutureTask.run(FutureTask.java:266) 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617) 在java.lang.Thread.run(Thread.java:745) 引起:java.lang.NoClassDefFoundError:org / springframework / jdbc / datasource / TransactionAwareDataSourceProxy 在org.springframework.orm.hibernate5.HibernateTransactionManager.setDataSource(HibernateTransactionManager.java:186) 在org.springframework.orm.hibernate5.HibernateTransactionManager.afterPropertiesSet(HibernateTransactionManager.java:360) 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) ......还有28个 引起:java.lang.ClassNotFoundException:org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy 在org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1274) 在org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1108) ......还有32个
2016年7月20日上午6:47:50 org.apache.catalina.core.ApplicationContext log 严重:StandardWrapper.Throwable org.springframework.beans.factory.BeanCreationException:创建名为' transactionManager'的bean时出错在ServletContext资源[/WEB-INF/springrest-servlet.xml]中定义:init方法的调用失败;嵌套异常是java.lang.NoClassDefFoundError:org / springframework / jdbc / datasource / TransactionAwareDataSourceProxy 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578) 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) at org.springframework.beans.factory.support.AbstractBeanFactory $ 1.getObject(AbstractBeanFactory.java:305) 在org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) 在org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301) 在org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772) 在org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:834) 在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537) 在org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:667) 在org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:633) 在org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:681) 在org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:552) 在org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:493) 在org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136) 在javax.servlet.GenericServlet.init(GenericServlet.java:158) 在org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1194) 在org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1110) 在org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1000) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4901) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5211) 在org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152) 在org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1403) 在org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1393) at java.util.concurrent.FutureTask.run(FutureTask.java:266) 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617) 在java.lang.Thread.run(Thread.java:745) 引起:java.lang.NoClassDefFoundError:org / springframework / jdbc / datasource / TransactionAwareDataSourceProxy 在org.springframework.orm.hibernate5.HibernateTransactionManager.setDataSource(HibernateTransactionManager.java:186) 在org.springframework.orm.hibernate5.HibernateTransactionManager.afterPropertiesSet(HibernateTransactionManager.java:360) 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) ......还有28个 引起:java.lang.ClassNotFoundException:org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy 在org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1274) 在org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1108) ......还有32个
答案 0 :(得分:0)
确保在类路径中包含org.springframework.jdbc-XX.jar。如果您使用maven或gradle编译/构建应用程序,请在依赖项中声明它...
的Maven:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>4.3.1.RELEASE</version>
</dependency>
摇篮:
compile("org.springframework.boot:spring-boot-starter")
compile("org.springframework:spring-jdbc")
根据需要更改版本。