spring+mybatis整合,org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class '${jdbc.driverClassName}

在使用spring+mybatis时会出现Cannot load JDBC driver class ${jdbc.driverClassName}之类的出错。

原因是在spring里使用org.mybatis.spring.mapper.MapperScannerConfigurer 进行自动扫描的时候,设置了sqlSessionFactory 的话,可能会导致PropertyPlaceholderConfigurer失效,也就是用${jdbc.username}这样之类的表达式,将无法获取到properties文件里的内容。 导致这一原因是因为,MapperScannerConigurer实际是在解析加载bean定义阶段的,这个时候要是设置sqlSessionFactory的话,会导致提前初始化一些类,这个时候,PropertyPlaceholderConfigurer还没来得及替换定义中的变量,导致把表达式当作字符串复制了。 但如果不设置sqlSessionFactory 属性的话,就必须要保证sessionFactory在spring中名称一定要是sqlSessionFactory ,否则就无法自动注入。又或者直接定义 MapperFactoryBean ,再或者放弃自动代理接口方式。

解决方案:将

<property name="sqlSessionFactory" ref="ysSqlSessionFactory"></property>

改成<property name="sqlSessionFactoryBeanName" value="ysSqlSessionFactory" />

转载:https://blog.csdn.net/downkang/article/details/17710259

spring+mybatis整合,org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class '${jdbc.driverClassName}

原文地址:https://www.cnblogs.com/xh--/p/11184098.html

时间: 2024-12-18 21:46:53

spring+mybatis整合,org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class '${jdbc.driverClassName}的相关文章

org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class

org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class '${jdbc.driverClassName}' at org.springfra

org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class &#39;com.microsoft.sqlserver.jdbc.SQLServerDriver &#39;

问题摘要: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.microsoft.sqlserver.jdbc.SQLServerDriver ' 原因:配置文件drive

Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException:

七月 17, 2014 4:56:01 下午 org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet [dispatcher] in context with path [] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemExc

jdbc连接oracle时报错 Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableC

错误: Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Communications link failure Last packet sent

org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user &#39;root&#39;@&#39;localhost&#39; (using password:

tationProcessor' to allow for resolving potential circular referencesDEBUG 2018-05-28 11:32:35,016 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory: Finished creating instance of bean 'org.springframework.context.annotatio

Could not open JDBC Connection for transaction; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Could not create connection to database server.

报错信息:Could not open JDBC Connection for transaction; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Could not create connection to database server.) 问题来源mysql-connecter-java 版本过低 如果你mysql的版本是m

Hibernate连接数据库问题org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory

一.使用hibernate无法连接数据库的问题: ERROR: HHH000231: Schema export unsuccessful (Access denied for user 'root'@'192.168.1.109' (using password: NO)) at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549) at org.ap

Java面试考点解析(3)-- 数据库篇、Spring+MyBatis整合

-------------------------------   一.数据库基础知识 -------------------------------   1.在进行数据库编程时,连接池有什么作用?  由于创建连接和释放连接都有很大的开销(尤其是数据库服务器不在本地时,每次建立连接都需要进行TCP的三次握手,释放连接需要进行TCP四次握手,造成的开销是不可忽视的),为了提升系统访问数据库的性能,可以事先创建若干连接置于连接池中,需要时直接从连接池获取,使用结束时归还连接池而不必关闭连接,从而避免

关于Spring配置 (Cannot find class [org.apache.commons.dbcp.BasicDataSource] 问题)

myeclipse抛出异常 1 org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.apache.commons.dbcp.BasicDataSource] for bean with name 'dataSource' defined in URL [file:/opt/app-w/apache-tomcat-7.0.54/webapps/telemetry/WEB-INF