- 浏览: 1379395 次
- 性别:
- 来自: 江西
文章分类
- 全部博客 (287)
- oracle (30)
- Java (73)
- MySQL (16)
- Myeclipse/eclipse (12)
- javascript (15)
- JSP/Servlet (7)
- maven (14)
- AJAX (2)
- JQuery (9)
- tomcat (8)
- spring (21)
- Linux (28)
- PHP (9)
- UI (1)
- 编程错误及处理 (38)
- 多线程 (18)
- hibernate (10)
- Web Service (3)
- struts2 (6)
- log4j (3)
- SVN (4)
- DWR (1)
- lucene (1)
- 正则表达式 (4)
- jstl (2)
- SSL (3)
- POI (1)
- 网络编程 (1)
- 算法 (2)
- xml (4)
- 加密解密 (1)
- IO (7)
- jetty (2)
- 存储过程 (1)
- SQL Server (1)
- MongoDB (1)
- mybatis (1)
- ETL (1)
- Zookeeper (1)
- Hadoop (5)
- Redis (1)
- spring cloud (1)
最新评论
-
ron.luo:
牛逼,正解!
maven设定项目编码 -
lichaoqun:
java.sql.SQLException: Can't call commit when autocommit=true -
Xujian0000abcd:
Thanks...
Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the clas -
renyuan2ni:
[i][b][u]引用[list]
[*][img][flas ...
Manual close is not allowed over a Spring managed SqlSession -
851228082:
宋建勇 写道851228082 写道<!-- 文件拷贝时 ...
maven设定项目编码
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.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:240) at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:371) at org.springframework.test.context.transaction.TransactionalTestExecutionListener$TransactionContext.startTransaction(TransactionalTestExecutionListener.java:513) at org.springframework.test.context.transaction.TransactionalTestExecutionListener.startNewTransaction(TransactionalTestExecutionListener.java:271) at org.springframework.test.context.transaction.TransactionalTestExecutionListener.beforeTestMethod(TransactionalTestExecutionListener.java:164) at org.springframework.test.context.TestContextManager.beforeTestMethod(TestContextManager.java:358) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:73) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class '${jdbc.driverClassName}' at org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1429) at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371) at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044) at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:202) ... 25 more Caused by: java.lang.ClassNotFoundException: ${jdbc.driverClassName} at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) at org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1420) ... 28 more
在spring里使用org.mybatis.spring.mapper.MapperScannerConfigurer 进行自动扫描的时候,设置了sqlSessionFactory 的话,可能会导致PropertyPlaceholderConfigurer失效,也就是用${jdbc.username}这样之类的表达式,将无法获取到properties文件里的内容。 导致这一原因是因为,MapperScannerConigurer实际是在解析加载bean定义阶段的,这个时候要是设置sqlSessionFactory的话,会导致提前初始化一些类,这个时候,PropertyPlaceholderConfigurer还没来得及替换定义中的变量,导致把表达式当作字符串复制了。 但如果不设置sqlSessionFactory 属性的话,就必须要保证sessionFactory在spring中名称一定要是sqlSessionFactory ,否则就无法自动注入。又或者直接定义 MapperFactoryBean ,再或者放弃自动代理接口方式。
就是这个org.mybatis.spring.mapper.MapperScannerConfigurer中配置的bean下有属性sqlSessionFactory,如果配置了,就去掉这个属性,变成如下:
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property value="com.hyq.showcase.mapper,com.hyq.common.core.mapper" name="basePackage" /> </bean>
以上的解决方案比较一般,在3.1.1版本中配置的时候提供了以下:
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.xxxx.dal.mapper" /> <property name="sqlSessionFactoryBeanName" value="ysSqlSessionFactory" /> <!-- <property name="sqlSessionFactory" ref="ysSqlSessionFactory"></property> --> </bean>
改用sqlSessionFactoryBeanName注入就没有问题(不要使用sqlSessionFactory属性注入,使用sqlSessionFactoryBeanName注入),因为这时不会立即初始化sqlSessionFactory,传入的只是名字,非bean,所以不会引发提前初始化问题。。
以上供参考!
引自:http://www.oschina.net/question/188964_32305
评论
1 楼
hyf002
2015-03-06
<property name="sqlSessionFactoryBeanName" value="ysSqlSessionFactory" />
<!-- <property name="sqlSessionFactory" ref="ysSqlSessionFactory"></property> -->
阿西吧,终于找到问题原因了,多谢:)
发表评论
-
ORA-12505, TNS:listener does not currently know of SID given in connect descript
2017-05-11 18:10 1361数据对接时需要连接对方的Oracle数据库,但程序在运行时出错 ... -
Failed to introspect annotations: interface com.xxx
2016-07-16 17:22 3865在使用maven打包发布项目时发现在tomcat容器中正常启动 ... -
MYSQL server has gone away
2016-07-08 20:08 644在使用命令source导入SQL数据时报错如下: 造成此问 ... -
java.io.NotSerializableException: java.util.ArrayList$SubList
2016-03-15 11:36 2862错误信息: 原代码: if (null != dto ... -
java.lang.IllegalStateException: Form too large586563>200000
2015-12-16 19:49 2038错误信息: java.lang.IllegalStateExc ... -
java.lang.IllegalStateException: Form too large586563>200000
2015-12-16 19:49 24错误信息: java.lang.IllegalStateExc ... -
The function size must be used with a prefix when a default namespace is not
2015-07-30 21:39 4227错误信息: 20:23:34.035 %PARSER_ERRO ... -
java.lang.NoSuchMethodError: org.springframework.expression.spel.SpelParserConfi
2015-07-30 09:41 9978错误信息: [WARNING] FAILED remoting ... -
getOutputStream() has already been called for this response
2015-07-24 09:55 2538错误信息: SEVERE: Servlet.service() ... -
spring aop未执行问题记录
2015-07-03 11:54 1435在类com.ipharmacare.plat.service. ... -
struts2传递参数时造成的404问题记录
2015-06-29 20:44 1050今天使用form表单提交数据时提示404错误,但当我直接在浏览 ... -
quorum.QuorumCnxManager: Cannot open channel to 2 at election address
2015-04-02 15:38 8338在进行hbase分布式安装时出现了如下信息: quorum.Q ... -
could only be replicated to 0 nodes, instead of 1
2015-03-28 17:51 2609用三台Linux搭建hadoop环 ... -
Does not contain a valid host:port authority: file:///
2015-03-08 15:15 1702Does not contain a valid host:p ... -
java.sql.SQLException: Can't call commit when autocommit=true
2015-01-30 11:22 4488错误信息: 一月 30, 2015 11:10:16 上午 o ... -
org.hibernate.TransactionException: nested transactions not supported
2014-07-25 14:06 10661使用hibernate4.3.5和spring4.0.3进行数 ... -
Shutting down 'proxoolDataSource' pool immediately [Shutdown Hook]
2014-07-19 23:03 1862错误信息如下: 原因是ProxoolDataSource的m ... -
org.apache.ibatis.binding.BindingException: Parameter 'ids' not found. Available
2014-06-13 16:01 1982MyBatis批量操作报错:Parameter 'xxxLis ... -
Manual close is not allowed over a Spring managed SqlSession
2014-05-28 21:34 26670整合spring与MyBatis时出现如下警告: [org.s ... -
log4j无日志输出
2014-05-21 15:31 1435今天在运行测试项目时发现没有日志输出(控制台和文件中都没日志输 ...
相关推荐
org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver' 出现异常原因,缺少数据库连接jar
org.apache.commons.lang.ClassUtils.class org.apache.commons.lang.Entities$ArrayEntityMap.class org.apache.commons.lang.Entities$BinaryEntityMap.class org.apache.commons.lang.Entities$EntityMap....
org.apache.commons.lang.BitField.class org.apache.commons.lang.BooleanUtils.class org.apache.commons.lang.CharEncoding.class org.apache.commons.lang.CharRange.class org.apache.commons.lang.CharSet...
总之,要解决`java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource`的问题,你需要确保你的项目正确包含了Apache Commons DBCP及其相关依赖,并正确配置了`BasicDataSource`。同时,了解...
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"/> <property name="url" value="jdbc:mysql://localhost:3306/mydb"/...
Apache Commons Math 3.6.1 是一个由Apache软件基金会开发的开源库,它提供了广泛的数学和统计功能,适用于各种编程任务。这个版本是3.6.1,意味着它是对之前版本的改进和增强,可能包括错误修复、性能优化以及新...
import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.httpclient.methods....
com.springsource.org.apache.commons.dbcp-sources-1.2.2.osgi.jar源码 jar包
jar包分享,你懂的 com.springsource.org.apache.commons.io-1.4.0.jar
com.springsource.org.apache.commons.dbcp_1.2.2.osgi.jar
com.springsource.org.apache.commons.logging-1.1.1.jar
在这个特定的错误中,我们看到的是`org.apache.commons.dbcp.BasicDataSource`,这是Apache Commons DBCP库中的一个类,用于管理数据库连接池。这个异常通常意味着在应用的类路径(ClassPath)中没有包含DBCP的jar...
本站为大家提供了org.apache.commons的jar包下载地址,Apache Commons包含了很多开源的工具,用于解决平时编程经常会遇到的问题,减少重复劳动,需要此类JAR包的朋友们欢迎前来下载使用。 基本简介 commons包,根据...
org.apache.poi:poi:4.1.2 org.apache.poi:poi-ooxml:4.1.2 org.apache.poi:poi-ooxml-schemas:4.1.2 org.apache.xmlbeans:xmlbeans:3.1.0 ...commons-codec:commons-codec:...org.apache.commons:commons-compress:1.19
commons-dbcp-1.2.2.jar commons-collections-3.2.1.jar commons-codec-1.3.jar commons-chain-1.1.jar commons-beanutils-1.6.jar 包含两个最常用的源码: commons-beanutils-1.6-src.zip commons-collections-...
<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="com.mysql.jdbc.Driver"/> <property name="url" value="jdbc:...
org.apache.commons 的 jar 包 org.apache.commons的jar包,Apache Commons包含了很多开源的工具,用于解决平时编程经常会遇到的问题,减少重复劳动,有需要的赶快来CSDN下载吧!
"org.apache.commons jar" 指的是这个项目中相关组件的集合,通常包含多个模块,每个模块专注于特定的编程任务。 1. **Apache Commons Lang**: 这个模块提供了许多高级字符串处理、日期和时间操作、数学计算以及...
jar包,官方版本,自测可用