在使用springboot集成mybaties遇到application.yml文件中数据库信息无法读取,导致连接不上报错Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Access denied for user ‘***’@‘localhost’ (using password: YES)

### Error querying database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Access denied for user '***'@'localhost' (using password: YES)
### The error may exist in com/example/springboot_mybatis/mapper/StudentMapper.xml
### The error may involve com.example.springboot_mybatis.mapper.StudentMapper.findAll
### The error occurred while executing a query
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Access denied for user '***'@'localhost' (using password: YES)

在这里插入图片描述原因是application.properties的优先级比yml文件高,先读取里面的数据,导致yml中配置不生效。

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐