Java JPA/Hibernate可用于Postgresql,但不能用于Mysql

Java JPA/Hibernate可用于Postgresql,但不能用于Mysql,java,mysql,hibernate,postgresql,jpa,Java,Mysql,Hibernate,Postgresql,Jpa,我正在尝试用MySQL替换我应用程序中的PostgreSQL。我认为替换persistence.xml文件中的就足够了: PostgreSQL: <property name="hibernate.connection.url" value="jdbc:postgresql://localhost/postgres"/> <property name="hibernate.connection.username" value=""/> <property name=

我正在尝试用MySQL替换我应用程序中的PostgreSQL。我认为替换persistence.xml文件中的
就足够了:

PostgreSQL:

<property name="hibernate.connection.url" value="jdbc:postgresql://localhost/postgres"/>
<property name="hibernate.connection.username" value=""/>
<property name="hibernate.connection.password" value=""/>
<property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
我不确定我做错了什么,我只是希望更换会很简单。在PostgreSQL中,一切都正常工作

Persistence.xml:

applicationContext.xml:

例外情况:

谢谢

编辑: 我故意从给定代码中删除用户名和密码。

com.mysql.jdbc.Driver
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/demo</property>
        <property name="hibernate.connection.username">root</property>
        <property name="hibernate.connection.password">root</property>
org.hibernate.dialogue.mysqldialogue jdbc:mysql://localhost:3306/demo 根 根
com.mysql.jdbc.Driver
org.hibernate.dialogue.mysqldialogue
jdbc:mysql://localhost:3306/demo
根
根

您缺少PostgreSQL的配置hibernate方言:

<property name="hibernate.connection.url" value="jdbc:postgresql://localhost/postgres"/>
<property name="hibernate.connection.username" value=""/>
<property name="hibernate.connection.password" value=""/>
<property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>

编辑:

配置中没有拼写:

<property name="hiberante.connection.url" value="jdbc:mysql://localhost:3306/GoOut2"/>

应该是

<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/GoOut2"/>


hibernate
,但不是
hibernate

您缺少PostgreSQL的配置hibernate方言:

<property name="hibernate.connection.url" value="jdbc:postgresql://localhost/postgres"/>
<property name="hibernate.connection.username" value=""/>
<property name="hibernate.connection.password" value=""/>
<property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>

编辑:

配置中没有拼写:

<property name="hiberante.connection.url" value="jdbc:mysql://localhost:3306/GoOut2"/>

应该是

<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/GoOut2"/>


hibernate
,但是不是
hibernate

你也可以发布会话工厂的启动消息吗?你可以使用给定的凭据信息从mysql工作台连接吗?你也可以发布会话工厂的启动消息吗?你可以使用给定的凭据信息从mysql工作台连接吗?我只是忘了将其添加到例如,但我的问题不是PostgreSQL,byt MySQL。我只是忘记将其添加到示例中,但我的问题不是PostgreSQL,byt MySQL。