急,java中spring和hibernate整合问题
开发javaweb的人应该知道就算现在最新的版本spring2.0除了mysql5.0其他的数据库都不支持自动提交功能,需要设置管理机制,我查了大量资料看到最简单的方法在...
开发java web的人应该知道就算现在最新的版本spring2.0除了mysql5.0其他的数据库都不支持自动提交功能,需要设置管理机制,我查了大量资料看到最简单的方法在applicationContext.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:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<tx:annotation-driven transaction-manager="transactionManager"
proxy-target-class="true" />
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation"
value="classpath:hibernate.cfg.xml">
</property>
</bean>
<bean id="NewUserDAO" class="dao.NewUserDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
</beans>import 当然我在NewUserDAO中也加人了org.springframework.transaction.annotation.Transactional;
@Transactional标签,可是我建立一个测试类居然报错Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'NewUserDAO' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.ExceptionInInitializerError
Caused by: java.lang.ExceptionInInitializerError
希望会的给我说下怎么回事?能有更好的简单的方法告诉我也行!谢谢了 展开
<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:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<tx:annotation-driven transaction-manager="transactionManager"
proxy-target-class="true" />
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation"
value="classpath:hibernate.cfg.xml">
</property>
</bean>
<bean id="NewUserDAO" class="dao.NewUserDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
</beans>import 当然我在NewUserDAO中也加人了org.springframework.transaction.annotation.Transactional;
@Transactional标签,可是我建立一个测试类居然报错Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'NewUserDAO' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.ExceptionInInitializerError
Caused by: java.lang.ExceptionInInitializerError
希望会的给我说下怎么回事?能有更好的简单的方法告诉我也行!谢谢了 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询