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 'root '@'localhost' (using password: YES))
### The error may exist in file [D:\eclipsefile\myssm\target\classes\test\mapping\UserMapper.xml]
### The error may involve test.Dao.IUserDao.selectByPrimaryKey
### The error occurred while executing a query
### 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 'root '@'localhost' (using password: YES))
### 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 'root '@'localhost' (using password: YES))
### The error may exist in file [D:\eclipsefile\myssm\target\classes\test\mapping\UserMapper.xml]
### The error may involve test.Dao.IUserDao.selectByPrimaryKey
### The error occurred while executing a query
### 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 'root '@'localhost' (using password: YES))
原因:
1,在jdbc属性配置文件中
url=jdbc:mysql://localhost:3306/test
user=root ....等尾部有空格存在,导致异常
(我的配置文件尾部有空格存在,害得我在找了半天,TMD就是几个空格的问题)
2.当前连接数据库的用户权限问题。新建一个用户,并赋予相应的数据操作权限
3.好好检查对应的配置.......