Spring BootでMySQLに接続時にエラーが出る

Spring BootでMySQLに接続時にエラーが出ました。

具体的には、Spring Boot で Spring Data JPA を使用してMySQLに接続するプログラムを書き、Maven installを実行したところエラーが起きました。

エラー内容は次のとおりです。

java.sql.SQLException: The server time zone value '???? (?W????)' 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.

対策

色々と調査して試したところ、設定ファイル(application.properties)のDB接続先(spring.datasource.url)を、次のように記述するとエラーが解消されて接続されます。

application.properties
 
spring.datasource.url=jdbc:mysql://localhost:3306/mysql?serverTimezone=JST

クエリ(?)をつけるところがポイントです。