SpringBoot connection mysql8.0 version - pit
In the most recent study Mu class network course - " two hours the Boot quick start the Spring ", an error occurs when using a spring boot connect to the database. Because the teacher's version 5.7 database, my database version 8.0, which in the case of Yihuhuhuapiao, the emergence of a database connection error, google countless content, has finally found a way to solve the problem in the vast network.
wrong description
Error : database connection, the need to configure the application-dev.yml file, the configuration file as follows:
server:
port: 8081
servlet:
context-path: /luckymoney
limit:
minMoney: 0.01
maxMoney: 9999
description: 最少要发${limit.minMoney}元,最多要发${limit.maxMoney}元
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/luckymoney
username: root
password: 0625
jpa:
hibernate:
ddl-auto: create
show-sql: true
Error contents:
Then find the appropriate content on the Internet, in fact, about the time zone errors There are many solutions. I was able to find a solution to the problem is to modify spring.datasource.url
spring:
datasource:
url: jdbc:mysql://localhost:3306/luckymoney?serverTimezone=UTC&characterEncoding=utf8&useUnicode=true&useSSL=true
即添加:?serverTimezone=UTC&characterEncoding=utf8&useUnicode=true&useSSL=true
Solves the problem, run the program again, still being given:
Error content:
This time the connection pool or initialization errors, but the problem is it takes a lot of time to find. In the solutions given below.
solution
The database password enclosed in single quotes , that's solved. But I need more specific principles to understand why springboot that when mysql 8.0 version connection password to use single quotes. (As if the password is not so enclosed need? But also a solution)
...
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/luckymoney?serverTimezone=UTC&characterEncoding=utf8&useUnicode=true&useSSL=true
username: root
password: '0625'
...
This time can be the perfect start up!