在学习MyBatis的过程中遇到的比较抽象的问题:
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.lang.RuntimeException: Driver com.mysql.cj.jdbc.Driver claims to not accept jdbcUrl, "jdbc:mysql://localhost:3306/mybatis"
### The error may exist in com/pitchynight/mybatisdemo/dao/mapper/UserMapper.java (best guess)
### The error may involve com.pitchynight.mybatisdemo.dao.mapper.UserMapper.list
### The error occurred while executing a query
### Cause: java.lang.RuntimeException: Driver com.mysql.cj.jdbc.Driver claims to not accept jdbcUrl, "jdbc:mysql://localhost:3306/mybatis"
成因和解决方法:
在Spring的properties文件中,在配置连接的时候给url填上了双引号:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url="jdbc:mysql://localhost:3306/mybatis"
spring.datasource.username=root
spring.datasource.password=123456
从而导致驱动无法识别这个url,修改即可.
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/mybatis
spring.datasource.username=root
spring.datasource.password=Fsy8097684164