我试图创建一个利用hibernate和h2的spring引导应用程序。从我在网上找到的这个可以做到,但我在启动应用程序时遇到问题。 Hibernate抱怨说它无法连接到我创建的h2数据库。春季/休眠中运行H2嵌入式数据库
Caused by: org.hibernate.HibernateException: Unable to make JDBC Connection [jdbc:h2:~/todo]
我的理论是,应用程序需要启动数据库是可用,但Hibernate是不是让不连接的应用程序启动。
我在这个理论的正确轨道上,是否有类似的问题,有人知道如何解决这个问题?
Hibernate的配置
**<?xml version="1.0" encoding="UTF-8"?>
<hibernate-configuration>
<session-factory>
<!--Database connection settings -->
<property name="connection.driver_class">com.mysql.cj.jdbc.Driver</property>
<property name="connection.url">jdbc:h2:~/todo</property>
<property name="connection.username">username</property>
<property name="connection.password" />
<!--Set the database dialect -->
<property name="dialect">org.hibernate.dialect.H2Dialect</property>
<!--Echo all executed SQL to stdout-->
<property name="show_sql">true</property>
<!--Drop and re-create the database schema on startup-->
<property name="hbm2ddl.auto">create</property>
<!--Name the annotated Entity classes -->
<mapping class="com.todo.beans.User" />
</session-factory>
</hibernate-configuration>**
H2配置
你在linux上吗? – Thihara