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.
分享到:
评论
是什么意思?