欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

idea中springboot項目連接數(shù)據(jù)庫報錯的原因解析

 更新時間:2020年12月24日 10:10:02   作者:SegmentFault博客  
這篇文章主要介紹了idea中springboot項目連接數(shù)據(jù)庫報錯的原因解析,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下

一.我在運用mybatis下報錯,反復(fù)檢查無邏輯問題,下圖為項目結(jié)構(gòu)截圖

二.最后總結(jié)問題如下:

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文件中手動添加驅(qū)動如下(沒有添加注釋的driver-class-name)

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

2)

報錯代碼:

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.jt.mapper.UserMapper.findAll

原因分析:pom.xml中,依賴mysql為高版本(8.0.22)此時任然報錯檢查properties/yml配置文件中的如下代碼

#加載Mapper映射文件
mapper-locations: classpath:/mybatis/mappers/*.xml

到此這篇關(guān)于idea中springboot項目連接數(shù)據(jù)庫報錯的原因解析的文章就介紹到這了,更多相關(guān)idea中springboot連接數(shù)據(jù)庫報錯內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論