Spring3与Hibernate4整合时出现了nested exception is java.lang.NoClassDefFoundError: Lorg/hibernate/cache/CacheProvider。
hibernate3的时候,用spring来控制sessionfactory用的可以是org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean,因为用的是hibernate4所以照猫画虎写了个org.springframework.orm.hibernate4.annotation.AnnotationSessionFactoryBean,发现没有这个类。那继续用hibernate3的那个,接着便有上一段的错误。
stackoverflow,用org.springframework.orm.hibernate4.LocalSessionFactoryBean
替换org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean。
In the Hibernate 4 the CacheProvider-related interfaces and classes has been removed. Now the RegionFactory related cache interfaces are available for secondary level caching.
Hibernate4已经把CacheProvider相关的接口和类移除,现在的RegionFactory关联的缓存接口在二级缓存中可用。
两者联系:
其实可以看到:
java.lang.Object org.springframework.orm.hibernate3.AbstractSessionFactoryBean org.springframework.orm.hibernate3.LocalSessionFactoryBean org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean
AnnotationSessionFactoryBean还是从LocalSessionFactoryBean继承的。
同时还发现了一个问题。声明式的事务管理中同时加了Annotation和xml也声明了。
xml声明是aop的方式,在方法中切进去。
<tx:annotation-driven transaction-manager="txManager"/> <bean id="txManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <tx:advice id="txAdvice" transaction-manager="txManager"> <tx:attributes> <tx:method name="add" read-only="true" /> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut expression="execution (public * com.my.service..*.*(..))" id="servicePointCut" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="servicePointCut"/> </aop:config>
@Transactional public void add(User user) { userDAO.save(user); Log log = new Log(); log.setName("output!"); logDAO.save(log); }
原文:http://www.roseindia.net/hibernate/hibernate4/Hibernate-4-AnnotationSessionFactoryBean.shtml
MAHOUT_LOCAL is not set;adding HADOOP_CONF_DIR to classpath,布布扣,bubuko.com
MAHOUT_LOCAL is not set;adding HADOOP_CONF_DIR to classpath
原文地址:http://blog.csdn.net/dhuwxs/article/details/26514547