完美解决org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.Per

已解决org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.Persiste

在这里插入图片描述

报错问题

粉丝群里面的一个小伙伴敲代码时发生了报错(当时他心里瞬间凉了一大截,跑来找我求助,然后顺利帮助他解决了,顺便记录一下希望可以帮助到更多遇到这个bug不会解决的小伙伴),报错信息如下:

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Cannot create PoolableConnectionFactory (Access denied for user '洪学添'@'localhost' (using password: YES))
### The error may exist in com/ssm/mapper/UserMapper.xml
### The error may involve com.ssm.mapper.UserMapper.findUserById
### The error occurred while executing a query
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Cannot create PoolableConnectionFactory (Access denied for user '洪学添'@'localhost' (using password: YES))

捕获到关键信息点:Failed to obtain JDBC Connection,意指JDBC连接失败,可能出现这个错误的地方,properties文件书写有误,需要先检查;如果仔细检查后没有问题,则继续检查是否发生命名冲突的问题。

在这里插入图片描述

解决方法

解决方法如下

在这里插入图片描述
对于原因2可以采取如下方法解决:
将原数据库配置文件properties
在这里插入图片描述
修改成:
在这里插入图片描述
最后在spring的配置文件中进行相应的更改即可。

福利

每周会送6本技术书籍包邮到家
由于博主时间精力有限,每天私信人数太多,没办法每个粉丝都及时回复
大家可以进社区裙或者添加博主微信
点击下方链接即可
http://t.csdn.cn/6kInJ

猜你喜欢

转载自blog.csdn.net/weixin_50843918/article/details/130674960
今日推荐