我想將帶有 hibernate/jpa 的數據庫添加到我的 java 應用程序中,但我收到各種錯誤消息,表明無法構建實體管理器工廠并且存在錯誤的時區(我猜我可以在本地服務器上修復)。我的 persistence.xml:<?xml version="1.0" encoding="UTF-8"?><persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0"> <persistence-unit name="org.hibernate.tutorial.jpa"> <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider> <properties> <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/> <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/golist2019"/> <property name="hibernate.connection.autocommit" value="false"/> <property name="hibernate.connection.username" value="root"/> <property name="hibernate.connection.password" value="root"/> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/> <property name="hibernate.connection.CharSet" value="utf8"/> <property name="hibernate.connection.characterEncoding" value="utf8"/> <property name="hibernate.connection.useUnicode" value="true"/> <property name="hibernate.show_sql" value="true"/> <property name="hibernate.hbm2ddl.auto" value="update"/> <!-- use encache provider--> <!--<property name="hibernate.cache.region.factory_class"--> </properties> </persistence-unit></persistence>
2 回答

GCT1015
TA貢獻1827條經驗 獲得超4個贊
修正你的時區!:
引起原因:com.mysql.cj.exceptions.InvalidConnectionAttributeException:服務器時區值“Mitteleurop?ische Sommerzeit”無法識別或代表多個時區。如果要利用時區支持,則必須配置服務器或 JDBC 驅動程序(通過 serverTimezone 配置屬性)以使用更具體的時區值。

繁花如伊
TA貢獻2012條經驗 獲得超12個贊
在 persistence.xml 中,將 hibernate.connection.url 更改為:
jdbc:mysql://localhost:3306/golist2019&serverTimezone=歐洲/阿姆斯特丹
添加回答
舉報
0/150
提交
取消