在使用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

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐