[英]Spring4 with Hibernate4 fails in standalone process
I'm failling to use Spring4 togather with Hibernate4 in a standalone process (no container like tomcat, WAS, ...) 我无法在一个独立进程中将Spring4与Hibernate4结合使用(没有像tomcat,WAS等容器)
How can I use Hibernate4, Spring4 and Spring data repositories togather in a standalone process? 如何在独立进程中使用Hibernate4,Spring4和Spring数据存储库?
However I confiugre Spring I allways get the same exception: 但是我一直认为Spring我总是遇到相同的异常:
Caused by: java.lang.NullPointerException
at org.hibernate.engine.transaction.internal.jta.JtaStatusHelper.getStatus(JtaStatusHelper.java:76)
at org.hibernate.engine.transaction.internal.jta.JtaStatusHelper.isActive(JtaStatusHelper.java:118)
at org.hibernate.engine.transaction.internal.jta.CMTTransaction.join(CMTTransaction.java:149)
When googling for this, I get pointet to some information about hibernate.transaction.jta.platform
and the docu for Hibernate 4.3 is here http://docs.jboss.org/hibernate/orm/4.3/devguide/en-US/html_single/#services-JtaPlatform 对此进行搜索时,我会指出一些有关
hibernate.transaction.jta.platform
信息,有关Hibernate 4.3的文档请参见http://docs.jboss.org/hibernate/orm/4.3/devguide/zh-CN/html_single /#服务,JtaPlatform
But the only option I see for my case would be org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform
but this still leads to the same error. 但是我看到的唯一选择是
org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform
但这仍然会导致相同的错误。
Here is my Spring config: 这是我的Spring配置:
<context:component-scan base-package="com.xx.yy" />
<jpa:repositories base-package="com.xx.zz.respositories"></jpa:repositories>
<bean name="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/culture" />
<property name="username" value="root" />
<property name="password" value="" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
<bean class="org.springframework.orm.jpa.JpaTransactionManager" id="transactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
<property name="jpaDialect">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />
</property>
</bean>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="jtaDataSource" ref="dataSource" />
<property name="packagesToScan" value="culture.matching.index.model" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="generateDdl" value="true" />
<property name="showSql" value="false" />
<property name="databasePlatform" value="org.hibernate.dialect.MySQLDialect" />
<property name="database" value="MYSQL" />
</bean>
</property>
<property name="jpaProperties">
<value>
hibernate.transaction.jta.platform=org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform
</value>
</property>
</bean>
@geoand的回答很有帮助: https : //github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-simple因此我从XML迁移到Java配置
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.