1) Must use ApplicationContext, can't use BeanFactory.
Example:
ApplicationContext factory = new ClassPathXmlApplicationContext(new String[]{"spring.xml"});
2) BeanNameAutoProxyCreator bean must include property as below.
<property name="proxyTargetClass" value="true"/>
Example:
<bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="proxyTargetClass" value="true"/>
<property name="interceptorNames">
<list><value>loggingAroundAdvisor</value></list>
</property>
<property name="beanNames">
<list><value>*world</value></list>
</property>
</bean>
<bean id="helloworld" class="com.xqstation.test.spring.HelloWorld"/>
3) jar files must have (Spring 1.2.8)
lib\aopalliance\aopalliance.jar,
lib\cglib\cglib-nodep-2.1_3.jar,
A very simple Spring AOP example is attached.
BeanFactory or ApplicationContext?
Users are sometimes unsure whether a BeanFactory or an ApplicationContext is best suited for use in a particular situation. A BeanFactory pretty much just instantiates and configures beans. An ApplicationContext also does that, and it provides the supporting infrastructure to enable lots of enterprise-specific features such as transactions and AOP.
本文详细介绍了在Spring框架中使用Aspect Oriented Programming (AOP)和Inversion of Control (IOC)的基本配置方法。包括如何正确配置ApplicationContext而非BeanFactory,如何设置BeanNameAutoProxyCreator以实现AOP代理,以及所需的jar文件列表。
239

被折叠的 条评论
为什么被折叠?



