spring什么声明式事务管理处错
org.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'dep...
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'deptBiz' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the class path or specify proxy interfaces.
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">
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation"
value="classpath:hibernate.cfg.xml">
</property>
</bean>
<bean id="txmanager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<tx:advice id="txAdvice" transaction-manager="txmanager">
<tx:attributes>
<tx:method name="get*" read-only="true"/>
<tx:method name="find*" read-only="true"/>
<tx:method name="search*" read-only="true"/>
<tx:method name="query*" read-only="true"/>
<tx:method name="del*" propagation="REQUIRED"/>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="do*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="*" propagation="REQUIRED" read-only="true"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut expression="execution(* com.biz.*.*(..))" id="serviceMethod"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="serviceMethod"/>
</aop:config>
<!-- DAO -->
<bean id="EmpDAO" class="com.DAO.impl.EmpDAOimpl">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="DeptDAO" class="com.DAO.impl.DeptDAOimpl">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<!-- Biz -->
<bean id="deptBiz" class="com.biz.DeptBiz">
<property name="deptdao" >
<ref bean="DeptDAO"/>
</property>
</bean>
</beans> 展开
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">
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation"
value="classpath:hibernate.cfg.xml">
</property>
</bean>
<bean id="txmanager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<tx:advice id="txAdvice" transaction-manager="txmanager">
<tx:attributes>
<tx:method name="get*" read-only="true"/>
<tx:method name="find*" read-only="true"/>
<tx:method name="search*" read-only="true"/>
<tx:method name="query*" read-only="true"/>
<tx:method name="del*" propagation="REQUIRED"/>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="do*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="*" propagation="REQUIRED" read-only="true"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut expression="execution(* com.biz.*.*(..))" id="serviceMethod"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="serviceMethod"/>
</aop:config>
<!-- DAO -->
<bean id="EmpDAO" class="com.DAO.impl.EmpDAOimpl">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="DeptDAO" class="com.DAO.impl.DeptDAOimpl">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<!-- Biz -->
<bean id="deptBiz" class="com.biz.DeptBiz">
<property name="deptdao" >
<ref bean="DeptDAO"/>
</property>
</bean>
</beans> 展开
2个回答
展开全部
报错显示是你的一个类错误,spring创建 deptBiz这个bean错误了。原因是Cannot proxy target class because CGLIB2 is not available
Exception:
Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the class path or specify proxy interfaces.
解决方法一:导入cglib-nodep-2.1_3.jar包,或者导入asm-2.2.3.jar和cglib-2.2.jar
解决方法二:为需要代理的目标类抽出接口。
Exception:
Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the class path or specify proxy interfaces.
解决方法一:导入cglib-nodep-2.1_3.jar包,或者导入asm-2.2.3.jar和cglib-2.2.jar
解决方法二:为需要代理的目标类抽出接口。
推荐于2016-10-20 · 知道合伙人数码行家
关注
展开全部
错误创建bean的名称为deptBiz的“定义在类路径资源的ApplicationContext-thistong.xml]:错误设置属性值;嵌套异常是org.springframework.beans.notwritablepropertyexception:无效的属性”deptBiz的bean类[com.thistong。 service.impl.userserviceimpl]:bean属性的EmpDAO
的'不写,或有一个无效的setter方法。
1、setter方法的参数类型不匹配的getter的返回类型导致。
2、为需要代理的目标类抽出接口。
的'不写,或有一个无效的setter方法。
1、setter方法的参数类型不匹配的getter的返回类型导致。
2、为需要代理的目标类抽出接口。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询