为扩展抽象类的所有类创建PointCut

时间:2011-06-22 10:48:55

标签: java spring aop

我有两个课程

com.home.learn.TryImpl1&

com.home.learn.TryImpl2

扩展了抽象类com.home.learn.Try。

我在春天创建了一个Aspect

<aop:config>
    <aop:pointcut id="pointcut" expression="execution(* com.home.learn.Try.*(..))" />
    <aop:aspect ref="aopDemo">
        <aop:around method="around" pointcut-ref="pointcut" />
    </aop:aspect>
</aop:config>

但是我收到以下错误

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'try' defined in file [C:\Users\admin\workspace\Spring_Aspect_pure_pojo\spring-learn.xml]: Initialization of bean failed; nested exception is java.lang.NoSuchMethodError: net.sf.cglib.proxy.Enhancer.setInterceptDuringConstruction(Z)V
Caused by: java.lang.NoSuchMethodError: net.sf.cglib.proxy.Enhancer.setInterceptDuringConstruction(Z)V
    at org.springframework.aop.framework.Cglib2AopProxy.getProxy(Cglib2AopProxy.java:178)
    at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:110)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:429)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:299)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:313)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1181)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:427)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:291)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
    at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:124)
    at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:68)
    at Main.main(Main.java:10)

有人可以帮忙吗? 我想在所有类中查看扩展抽象类com.home.learn.Try

的所有方法

1 个答案:

答案 0 :(得分:2)

<aop:pointcut id="pointcut" expression="execution(* com.home.learn.Try+.*(..))" />