1)報錯代碼:Caused by: java.lang.RuntimeException: Failed to load driver class com.mysql.cj.jdbc.Driver in either of HikariConfig class loader or Thread context classloader at com.zaxxer.hikari.HikariConfig.setDriverClassName(HikariConfig.java:486)
緣由:pom.xml文件中mysql依賴版本低(5.1.6),但並無在properties或者yml文件中手動添加驅動以下(沒有添加註釋的driver-class-name)java
spring: datasource: url: jdbc:mysql://127.0.0.1:3306/jtdb?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&autoReconnect=true&allowMultiQueries=true username: root password: root #driver-class-name: com.mysql.cj.jdbc.Driver #driver-class-name: com.mysql.jdbc.Driver
ps:下面兩個配置均可以讓低版本mysql依賴下的項目運行,但第二個會報錯如圖
driver-class-name: com.mysql.cj.jdbc.Driver
driver-class-name: com.mysql.jdbc.Driver
mysql
2)
報錯代碼:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.jt.mapper.UserMapper.findAll
緣由分析:pom.xml中,依賴mysql爲高版本(8.0.22)此時任然報錯檢查properties/yml配置文件中的以下代碼spring
#加載Mapper映射文件 mapper-locations: classpath:/mybatis/mappers/*.xml
初學總結,若有錯誤感謝指出,不勝感激!sql