[url]http://wukaxi.iteye.com/blog/1402143[/url]
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:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:p="http://www.springframework.org/schema/p"
[color=red]xmlns:aop="http://www.springframework.org/schema/aop"[/color]
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
[color=red]http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd [/color]
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"
default-autowire="byName" default-lazy-init="true">
出现这个异常,spring框架AOP才用JDK动态代理只能对实现了接口的类实现动态代理,而不能针对类,我自己在搭建项目的时候没有用接口的模式,所以在应用启动时候,配置AOP事务 的时候会扫描你的service层,service层用到了Dao层的接口代理模式(spring 默认) 因为我没有采用接口模式编程,所以报错...
如果不才用接口模式那么 就要用CGLIB
而CGLIB是针对类实现代理,(主要生成一个子类,覆盖其中的方法)
因为是继承,所以该类或方法最好不要声明成final的类...
在applicationContext.xml 配置中加上
<aop:aspectj-autoproxy proxy-target-class="true"/>
把cglib.jar导入工程中即可以
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:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:p="http://www.springframework.org/schema/p"
[color=red]xmlns:aop="http://www.springframework.org/schema/aop"[/color]
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
[color=red]http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd [/color]
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"
default-autowire="byName" default-lazy-init="true">
出现这个异常,spring框架AOP才用JDK动态代理只能对实现了接口的类实现动态代理,而不能针对类,我自己在搭建项目的时候没有用接口的模式,所以在应用启动时候,配置AOP事务 的时候会扫描你的service层,service层用到了Dao层的接口代理模式(spring 默认) 因为我没有采用接口模式编程,所以报错...
如果不才用接口模式那么 就要用CGLIB
而CGLIB是针对类实现代理,(主要生成一个子类,覆盖其中的方法)
因为是继承,所以该类或方法最好不要声明成final的类...
在applicationContext.xml 配置中加上
<aop:aspectj-autoproxy proxy-target-class="true"/>
把cglib.jar导入工程中即可以