springboot項目連接數據庫的時候報錯,大概意思是被拒絕訪問了
媽耶要吐血了,找了一上午,修改了有的說用戶名用root可能會報錯我把用戶名改了,有的說權限不夠,我改了訪問mysql的權限都沒什麼用,最後看了一個大佬的博客才知道是因爲配置文件格式的問題,如果用properties配置是沒有問題的,但是用yml就會報錯。
這是我之前的application.yml中數據庫的配置,看起來一點毛病都沒有,但是死活不對。
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/mybatis?useSSL=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC
username: wanide
password: 000000
下面這樣就對了,給六個0加上雙引號,這樣獲取到的密碼纔不會錯!!!
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/mybatis?useSSL=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC
username: wanide
password: "000000"
絕了絕了,tui!