YML file configuration under springboot project

Time:2021-2-23

Connection database parameters

spring.datasource.url:jdbc:mysql://10.159.3.253:3306/yxkj?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&autoReconnect=true&allowMultiQueries=true

serverTimezone:serverTimezone=GMT%2B8

East 8 District, Beijing time
serverTimezone=GMT%2B8

useUnicode=true

For example: MySQL database uses GBK code, while project database uses UTF-8 code. At this time, if useunicode = true & characterencoding = UTF-8 is added, the effect is as follows:
1. When saving data:

When the database stores the project data, it will first decode the data into bytecode in UTF-8 format, and then store the decoded bytecode in the database with GBK code again.

2. When taking data:

When fetching data from the database, the database will first decode the data in the database into bytecode in GBK format, then encode the decoded bytecode in UTF-8 format again, and finally return the data to the client.

characterEncoding=utf8

Characterencoding = utf8 tells the database that this connection transmits utf8 data. The project is utf8, and the database is other encoding. During persistence, the utf8 data of the project will be converted into the format stored in the database. The same is true for data fetching from the database.
If the project and database are utf8, it is unnecessary to write

allowMultiQueries=true

1. It can carry semicolon after SQL statement to realize multi statement execution.
2. It can execute batch processing and issue multiple SQL statements at the same time.

autoReconnect=true

When the database connection is interrupted abnormally, do you want to connect again automatically?