1、打開網頁時候報錯,idea報錯
java.sql.SQLException: The server time zone value '�й���ʱ��' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the 'serverTimezone' configuration property) to use a more specifc time zone value if you want to utilize time zone support.
2、時區問題
啟動springboot項目,然后訪問數據庫,報You must configure either the server or JDBC driver (via the serverTimezone conf)的錯誤,原因
因為安裝mysql的時候時區設置的不正確 mysql默認的是美國的時區,而我們中國大陸要比他們遲8小時,采用+8:00格式
使用的數據庫是MySQL,從上面圖看出SpringBoot2.3在你沒有指定MySQL驅動版本的情況下它自動依賴的驅動是8.0.12很高的版本,這是由於數據庫和系統時區差異所造成的,在jdbc連接的url后面加上serverTimezone=GMT即可解決問題,如果需要使用gmt+8時區,需要寫成GMT%2B8,否則會被解析為空。再一個解決辦法就是使用低版本的MySQL jdbc驅動,5.1.28不會存在時區的問題。
加上這個 ?serverTimezone=UTC
spring.datasource.url=jdbc:mysql://localhost:3306/online_ssm?serverTimezone=UTC
如
spring.datasource.driver-class-name =com.mysql.cj.jdbc.Driver spring.datasource.url=jdbc:mysql://localhost:3306/online_ssm?serverTimezone=UTC spring.datasource.username=root spring.datasource.password=qw123456
3、問題解決