我已经用 appfuse 创建了我的 J2EE 应用程序,我想将一些数据保存到数据库中,但是 hibernante 配置中的问题,这是一个例外:
警告 [http-8080-1] ConnectionProviderInitiator.initiateService(143) | HHH000181:没有遇到适当的连接提供程序,假设应用程序将提供连接 juin 07, 2013 5:16:05 PM org.apache.catalina.core.StandardWrapperValve 调用严重:Servlet.service() 用于 servlet 面引发异常 org.hibernate。 HibernateException:未设置“hibernate.dialect”时,连接不能为空
这是 pom.xml 中的数据库配置:
<dbunit.dataTypeFactoryName>org.dbunit.ext.mysql.MySqlDataTypeFactory</dbunit.dataTypeFactoryName>
<dbunit.operation.type>CLEAN_INSERT</dbunit.operation.type>
<hibernate.dialect>org.hibernate.dialect.MySQL5InnoDBDialect</hibernate.dialect>
<jdbc.groupId>mysql</jdbc.groupId>
<jdbc.artifactId>mysql-connector-java</jdbc.artifactId>
<jdbc.version>5.1.22</jdbc.version>
<jdbc.driverClassName>com.mysql.jdbc.Driver</jdbc.driverClassName>
<!-- <jdbc.url>jdbc:mysql://localhost/${db.name}?createDatabaseIfNotExist=true&amp;useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true</jdbc.url> -->
<jdbc.url>jdbc:mysql://localhost/castor</jdbc.url>
<jdbc.username>root</jdbc.username>
<jdbc.password></jdbc.password>
如果我配置文件 hibernate.cfg.xml 服务器无法启动:
<hibernate-configuration>
<session-factory>
<mapping class="org.appfuse.model.Role"/>
<mapping class="com.geviteam.castor.webapp.model.TrajetModel"/>
</session-factory>
</hibernate-configuration>