Spring+MyBatis时Access denied for user '高欢欢'@'localhost' (using password: YES)的异常解决方案

  今天在做spring+mybatis整合的时候系统只要一运行就会报下面的错误,搞了几个小时硬是没有找的原因

 1 警告: com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@7de1c0d3 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception: 
 2 java.sql.SQLException: Access denied for user '高欢欢'@'localhost' (using password: YES)
 3     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1078)
 4     at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4190)
 5     at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4122)
 6     at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:927)
 7     at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1709)
 8     at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1252)
 9     at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2486)
10     at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2519)
11     at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2304)
12     at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:834)
13     at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
14     at sun.reflect.GeneratedConstructorAccessor7.newInstance(Unknown Source)
15     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
16     at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
17     at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
18     at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:416)
19     at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:346)
20     at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:135)
21     at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
22     at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
23     at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
24     at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
25     at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
26     at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
27     at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)

将C3P0换成了Druid也是不行,正准备放弃的时候,在网上看到一篇文章说是数据库配置文件有问题,马上进行了一番操作

竟然是上图中的

username

出现问题,随即将其修改为user即可,

但是又出现了下面的问题

就是你的spring版本要和Mybatis-spring和spring的版本要相对应

具体参考下面即可

 

posted @ 2019-07-17 21:38  演绎、白色舞步  阅读(357)  评论(0编辑  收藏  举报