在项目中集成hibernate时,在applicationContext.xml中创建sessionFactory,配置如下:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="SystemDataSource"></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.jdbc.batch_size">20</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>hbm/User.hbm.xml</value>
</list>
</property>
</bean>
提示如下错误:
Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/transaction/TransactionManager
根据网上的解决办法,引入了jat.jar后问题解决。
但是报错信息变成了:
java.lang.NoClassDefFoundError: org/apache/commons/collections/SequencedHashMap
于是引入了commons-collections-2.1.1.jar之后问题解决
但是又出现了新的问题:
Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: net/sf/cglib/proxy/CallbackFilter
于是引入了cglib-2.1.3.jar之后文件解决
但是又出现了新的问题:
Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/objectweb/asm/Type
于是引入了asm.jar之后问题解决
调用HibernateDaoSupport.getHibernateTemplate().find()时提示:
Exception in thread "main" java.lang.NoClassDefFoundError: antlr/ANTLRException
于是引入了antlr-2.7.6.jar之后问题解决