今天遇到这样的一个问题:
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'zhanghaoyu'@'localhost' (using password: YES))
大概意思是我mybatis配置有问题,导致无法连接jdbc。
于是我去翻xml,发现好像都对,查了查jdbc的jar包发现也在。就有点懵了,于是赶紧百度看看。
几经波折后发现,原来是我jdbc.properties中的username和系统重名了,有图为证:
现在我们只需在jdbc.properties中把username,password都换个名字就好了,这也是为什么jdbc.properties里的参数都要用jdbc.xxx开头的原因。
OK,问题完美解决!