這個是我找到的一個比較好的搭建步驟,建議學着看官網,由於官網確定是對的,網站論壇的不知道誰搞得能不能弄出來還不必定java
https://www.jianshu.com/p/ca185e2b19femysql
步驟大概是: 一、創建springboot 項目 二、引入pom所需 三、寫各個層 四、檢查收據庫 5 run。spring
步驟一步沒錯,可是跑不起來。sql
我一直在糾結一個報錯,下面整理錯誤緣由:數據庫
【1】java.sql.SQLNonTransientConnectionException: CLIENT_PLUGIN_AUTH is required
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:110) ~[mysql-connector-java-8.0.20.jar:8.0.20]express
緣由:這個錯是數據庫版本不一致,個人數據庫沒有用新版mysql,用的仍是5.x的因此這個就報錯了。springboot
解決方法: 默認pom.xml 中 mysql不加version標籤,會加載最新的,我要用低版本,就得加上。就不報這個錯了。
app
【2】Error creating bean with name 'userController': Unsatisfied dependency expressed through field 'userServer'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userServerimpl': Unsatisfied dependency expressed through field 'userMapper'; nested exce...... is java.lang.IllegalStateException: Cannot load driver class: com.mysql.cj.jdbc.Driverspring-boot
報錯緣由: 是驅動報名不同。靠,很久不用mysql想不到報名都改了。我一直覺得是 那塊註解配置沒有映射好。
spring.datasource.driver-class-name = com.mysql.cj.jdbc.Driver
學習
解決方法:com.mysql.cj.jdbc.Driver ==> com.mysql.jdbc.Driver
version 8.x ==========> 5.x
另外推薦一個網站,裏面學習springboot都是中文的,還挺不錯有源碼,只能學習用不能商用哦~~