spring-4.2.5 hibernate-5.1.0
spring整合hibernate时想使用spring提供的sessionfactory遇到下面的异常:
警告: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.apache.commons.dbcp.BasicDataSource] for bean with name 'myDataSource' defined in ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource
在网上搜了一下,都是说缺少了commons-dbcp和commons-pool这两个包,我都加到lib目录下之后问题依然存在,求解?
以下是spring的配置,copy官方文档的
User.hbm.xml org.hibernate.dialect.MySQLDialect
很明显是少了commons-dbcp和commons-pool这两个包。
你只是copy到lib下,有没有build path-->add to build path?