java - 运行项目时如何解决Hibernate的错误?
问题描述
当我运行我的网络应用程序时,会显示以下错误。
你能帮我修一下吗?
我正在使用hibernate框架,项目运行成功,但是在添加了一个restful web services并将其删除后,项目抛出了这个错误。
如果您愿意,我会向您展示更多信息。
Deploying on WildFly Application Server
profile mode: false
debug mode: false
force redeploy: true
Undeploying ...
Initial deploying px-fs-web-stage to C:\Users\HP\Desktop\Stage 2018\jboss-eap-7.1\standalone\deployments\px-fs-web-stage-1.0-SNAPSHOT.war
Completed initial distribution of px-fs-web-stage
Deploying C:\Users\HP\Desktop\Stage 2018\jboss-eap-7.1\standalone\deployments\px-fs-web-stage-1.0-SNAPSHOT.war
"{\"WFLYCTL0080: Les services ont échoué\" => {\"jboss.persistenceunit.\\\"px-fs-web-stage-1.0-SNAPSHOT.war#ma.px.fs.stage_px-fs-web-stage_war_1.0-SNAPSHOTPU\\\"\" => \"org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set\"}}"
cd C:\Users\HP\Desktop\Stage 2018\sypex-stage\px-fs-web-stage; "JAVA_HOME=C:\\Program Files\\Java\\jdk1.8.0_161" cmd /c "\"\"C:\\Program Files\\NetBeans 8.2\\java\\maven\\bin\\mvn.bat\" -Dnetbeans.deploy=true -Dmaven.ext.class.path=\"C:\\Program Files\\NetBeans 8.2\\java\\maven-nblib\\netbeans-eventspy.jar\" -Dfile.encoding=UTF-8 package\""
Scanning for projects...
我的 hbm.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"
default-autowire="byName" default-lazy-init="true">
<context:annotation-config />
<beans profile="default" default-lazy-init="true">
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:/SypexXADS" />
</bean>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="packagesToScan">
<list>
<value>ma.px.management.repository.service.bo</value>
</list>
</property>
<property name="jtaDataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="databasePlatform" value="org.hibernate.dialect.MySQLDialect" />
</bean>
</property>
<property name="jpaPropertyMap">
<map>
<entry key="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform"/>
<entry key="hibernate.transaction.factory_class" value="org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory" />
<entry key="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup" />
<entry key="hibernate.hbm2ddl.auto" value="none" />
<entry key="hibernate.max_fetch_depth" value="1" />
<entry key="hibernate.connection.release_mode" value="auto" />
<entry key="hibernate.transaction.flush_before_completion" value="true" />
<entry key="hibernate.transaction.auto_close_session" value="true" />
<entry key="hibernate.enable_lazy_load_no_trans" value="true" />
</map>
</property>
</bean>
<jpa:repositories base-package="ma.px.management.repository.service.dao" entity-manager-factory-ref="entityManagerFactory" />
<tx:jta-transaction-manager />
</beans>
</beans>
我没有更改休眠配置中的任何内容。我只是从我的 web.xml 中删除了一个 web 服务 servlet,注意它是一个 maven 项目
谢谢你。
解决方案
您没有hibernate.dialect
使用数据库方言类作为值将其添加到您的 jpaPropertyMap
下面是 MySQL 的示例
<property name="jpaPropertyMap">
<map>
<entry key="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
...other items
</map>
</property>
推荐阅读
- ios - SceneKit - 如何平铺自定义多边形
- java - Apache beam KvCoder(StringUtf8Coder,TableRowJsonCoder) 不是确定性的,因为
- angular - 使用自己的类型发布角度包 - 类型参考包含错误的路径
- python - Python根据来自另一个数据帧的多个条件将值分配给新数据帧,例如时间表
- node.js - GCP App Engine Vue.js 部署 500 服务器错误
- android-studio - 如何让用户将图片从他们的画廊上传到 Android Studio 中的特定文件路径?
- google-apps-script - Google Apps 脚本 - 库中函数与脚本中函数的行为差异
- woocommerce - 在 Woocommerce 可变产品中将单一变体选项设置为默认值
- c++ - 使用 CRTP 时如何在下面的代码中声明变量类型 X
- javascript - 从 javascript POST 重新加载剃须刀页面