记录使用springboot jpa的一次异常(java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä')

1.控制台会输出以下标红的信息

Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.

解决办法

可以根据提示把连接驱动类com.mysql.jdbc.Driver改为com.mysql.cj.jdbc.Driver,当然不做更改也不会报错

2.会出现以下异常信息

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.

解决办法

作为数据库驱动的url后的第一个加上serverTimezone=UTC参数

jdbc:mysql://localhost:3306/growproject?serverTimezone=UTC&useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useSSL=false

3.如果还出现类似以下的异常

org.hibernate.AnnotationException: No identifier specified for entity: com.example.growproject.domain.MenuEntity

1)出现原因,实体类中缺少@Id注解记录使用springboot jpa的一次异常(java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä')
2)解决办法,为实体类的相关主键加上@Id即可

4.参考文章:

org.hibernate.AnnotationException: No identifier specified for entity:
java.sql.SQLException: The server time zone value ‘Öйú±ê׼ʱ¼ä’