大兄弟们,你们有谁遇到这个错误吗?
如果配置了数据源不能连接,报这个
{
"timestamp": "2018-12-05T02:54:43.951+0000",
"status": 500,
"error": "Internal Server Error",
"message": "nested exception is org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.\r\n### The error may exist in com/imooc/mapper/UsersMapper.java (best guess)\r\n### The error may involve com.imooc.mapper.UsersMapper.selectOne\r\n### The error occurred while executing a query\r\n### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.",
}
就去检查数据源配置信息
导入org.mybatis.spring.annotation.MapperScan服务器报和你一样的错,换成tk.mybatis.spring.annotation.MapperScan,服务器响应超级慢,然后最后报个500
在项目中搜索BaseInsertProvider 这个类,发现只有
tk.mybatis.spring.annotation.MapperScan
这个包中有,改为导入该类。
把SpringBoot的Application启动类的@MapperScan注解导入包换成import org.mybatis.spring.annotation.MapperScan;试一下