【发布时间】:2016-08-15 07:31:47
【问题描述】:
我第一次尝试使用 Jersey,但在尝试在本地机器上运行 Jersey 服务器时出现此异常:
线程“主”org.hibernate.HibernateException 中的异常:当未设置“hibernate.dialect”时,对 DialectResolutionInfo 的访问不能为空
这是我的 hibernate.cfg.xml:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration SYSTEM
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect"> org.hibernate.dialect.MySQLDialect </property>
<property name="hibernate.connection.driver_class"> com.mysql.jdbc.Driver </property>
<!-- Assume test is the database name -->
<property name="hibernate.connection.url"> jdbc:mysql://localhost/mydb </property>
<property name="hibernate.connection.username"> root </property>
<property name="hibernate.connection.password"> </property>
<!-- List of XML mapping files -->
<mapping class="annotations.Person"></mapping>
</session-factory>
</hibernate-configuration>
Jersey 的 config.yml 包含这部分:
# Database settings.
database:
# the name of the JDBC driver, mysql in our case
driverClass: com.mysql.jdbc.Driver
# the username
user: root
# the password
password:
# the JDBC URL; the database is called DWGettingStarted
url: jdbc:mysql://localhost:3306/mydb
如何解决这个异常?
【问题讨论】:
标签: java mysql hibernate jersey