请帮我为我的项目设置evnvers。在它下面我的“entityManagerFactory”bean与Envers
弹簧context.xml中
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
depends-on="flyway">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="com.example.cns.*" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.hbm2ddl.auto">validate</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.temp.use_jdbc_metadata_defaults">false</prop>
<!-- <prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory</prop> -->
<prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<!-- Listeners for Hibernate Envers -->
<prop key="hibernate.ejb.event.post-insert">
org.hibernate.ejb.event.EJB3PostInsertEventListener,
org.hibernate.envers.event.AuditEventListener
</prop>
<prop key="hibernate.ejb.event.post-update">
org.hibernate.ejb.event.EJB3PostUpdateEventListener,
org.hibernate.envers.event.AuditEventListener
</prop>
<prop key="hibernate.ejb.event.post-delete">
org.hibernate.ejb.event.EJB3PostDeleteEventListener,
org.hibernate.envers.event.AuditEventListener
</prop>
<prop key="hibernate.ejb.event.pre-collection-update">
org.hibernate.envers.event.AuditEventListener
</prop>
<prop key="hibernate.ejb.event.pre-collection-remove">
org.hibernate.envers.event.AuditEventListener
</prop>
<prop key="hibernate.ejb.event.post-collection-recreate">
org.hibernate.envers.event.AuditEventListener
</prop>
<!-- Properties for Hibernate Envers -->
<prop key="org.hibernate.envers.audit_table_suffix">_H</prop>
<prop key="org.hibernate.envers.revision_field_name">AUDIT_REVISION</prop>
<prop key="org.hibernate.envers.revision_type_field_name">ACTION_TYPE</prop>
<prop key="org.hibernate.envers.audit_strategy">org.hibernate.envers.strategy.ValidityAuditStrategy</prop>
<prop key="org.hibernate.envers.audit_strategy_validity_end_rev_field_name">AUDIT_REVISION_END</prop>
<prop key="org.hibernate.envers.audit_strategy_validity_store_revend_timestamp">True</prop>
<prop key="org.hibernate.envers.audit_strategy_validity_revend_timestamp_field_name">AUDIT_REVISION_END_TS</prop>
</props>
</property>
</bean>
的pom.xml
<spring.version>3.1.2.RELEASE</spring.version>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-envers</artifactId>
<version>4.2.1</version>
</dependency>
通过以上设置我正在
SEVERE: Exception occurred when intialization
java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
任何帮助解决此问题表示赞赏。谢谢 莫汉
答案 0 :(得分:0)
您不需要为版本4.x
定义envers侦听器请参阅http://docs.jboss.org/hibernate/core/4.0/devguide/en-US/html/ch15.html第15.1节
这可能会简化您的问题。
答案 1 :(得分:0)
根据文件Joss Docs
重要事项与以前的版本不同,您不再需要指定 Hibernate配置文件中的监听器。只是把Envers 类路径上的jar就足够了 - 监听器将被注册 自动。