在学习ssm时,发现用ioc容器配置DruidDataSource时报了两个错误

本文讲述了开发者在使用SpringBoot与MySQL集成时遇到的连接问题,涉及到用户名冲突和`driver`属性转换失败。解决方法是将`jdbc.username`用于配置,以及将`driver`属性改为`driverClassName`。
摘要由CSDN通过智能技术生成

 错误:循环报错errorCode 1045, state 28000

严重: create connection SQLException, url: jdbc:mysql://localhost:3306/studb, errorCode 1045, state 28000
java.sql.SQLException: Access denied for user '�羊'@'localhost' (using password: YES)

在其他博客文章看到说是mysql的username名字冲突,遂改为jdbc.username

报新错误

错误:dataSource

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [spring-01.xml]: Failed to convert property value of type 'java.lang.String' to required type 'java.sql.Driver' for property 'driver'; Cannot convert value of type 'java.lang.String' to required type 'java.sql.Driver' for property 'driver': no matching editors or conversion strategy found

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [spring-01.xml]: Failed to convert property value of type 'java.lang.String' to required type 'java.sql.Driver' for property 'driver'; Cannot convert value of type 'java.lang.String' to required type 'java.sql.Driver' for property 'driver': no matching editors or conversion strategy found

最后ioc配置里,driver也需改为driverClassName,运行成功

综上:需将jdbc.properties配置文件里面的username改为jdbc.username,并且将,ioc容器里面的<property name="driver" value="${driver}"/>改为<property name="driverClassName" value="${driver}"/>

小白一枚,暂不知具体原因...

  • 15
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值