数据源配置注意点
1、驱动选择区别:com.mysql.cj.jdbc.Driver、com.mysql.jdbc.Driver
2、时区注意:serverTimezone=GMT%2B8
时区不配置,可能导致异常(因为mysql默认使用的是美国时间,比中国早8个小时):
java.sql.SQLException: The server time zone value '�й���ʱ��' is unrecognized or represents more than one time zone
我的配置
#数据源配置
spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/essm?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&useSSL=false
spring.datasource.username=root
spring.datasource.password=###
具体更多细节参考:https://www.cnblogs.com/qubo520/p/8483595.html 这篇文章