Error creating bean with name 'dataSource' defined in class path resource [applicationContext.xml]:

Error creating bean with name ‘dataSource’ defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property ‘classDriver’ of bean class [com.mchange.v2.c3p0.ComboPooledDataSource]: Bean property ‘classDriver’ is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?

配置Spring的数据库链接池时出现这个意思,由于框架的配置会出现很多不同的问题。这里只写我自己遇到的(作为初学者)。
上面这个问题的大概意思是:
数据库连接池存在一个无效的classDriver 属性。
求问之后才知道,数据库连接池是别人制作出来的产品不同的数据库链接池,配置也不相同。
以下是我使用的数据库链接池:
这里写图片描述
而后面的${jdbc.jdbcUrl}等是与我之前配置的db.properties文件里面的内容一一对应。
这里写图片描述

db.properties文件

jdbc.jdbcUrl=jdbc:mysql://localhost:3306/zycrm?characterEncoding=utf-8
jdbc.driverClass=com.mysql.jdbc.Driver
jdbc.user=root
jdbc.password=root

c3p0连接池的正确配置方法;

<!-- 链接数据库连接池 先开启事物,再链接数据库 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource"></property>
</bean>
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    <property name="jdbcUrl" value="${jdbc.jdbcUrl}"></property>
    <property name="driverClass" value="${jdbc.driverClass}"></property>
    <property name="user" value="${jdbc.user}"></property>
    <property name="password" value="${jdbc.password}"></property>
</bean>
  • 8
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 6
    评论
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

踏雪须眉

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值