执行结果:
Jul 06, 2016 12:30:03 AM org.springframework.context.support.ClassPathXmlApplicationContext prepareRefresh INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@6924181b: startup date [Wed Jul 06 00:30:03 CST 2016]; root of context hierarchy Jul 06, 2016 12:30:03 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions INFO: Loading XML bean definitions from class path resource [bean-aop.xml] before Execute! --class name: AddCalculator, method name: getResult [3.0, 1.0] 4.0 before Execute! --class name: SubCalculator, method name: getResult [3.0, 1.0] 2.0 三 总结项目中, 如果不用AOP 我们往往要为每个方法添加日志代码, 十分难于维护, 可读性也大大下降, 而AOP的出现, 就能解决这些问题。