日期:2014-05-17 浏览次数:20732 次
package com.luojia.zwc;
public class EatAction {
public void eat(){
System.out.println("eat food");
}
}
package com.luojia.zwc;
public class CommonAction {
public void wash(){
System.out.println("wash your hands before eating food!");
}
}
<?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:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
<bean id="eat" class="com.luojia.zwc.EatAction" />
<bean id="common" class="com.luojia.zwc.CommonAction" />
<aop:config>
<aop:aspect id="deal" ref="common">
<aop:pointcut id="target" expression="execution(* com.luojia.zwc.*.*(..))" />
<aop:before method="wash" pointcut-ref="target" />
</aop:aspect>
</aop:config>
</beans>
package com.luojia.zwc;
import java.beans.XMLDecoder;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Test {
public static void main(String[] args) {
ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext-aop.xml");
EatAction ea = (EatAction) ac.getBean("eat",EatAction.class);
ea.eat();
}
}
十月 23, 2013 5:55:15 下午 org.springframework.context.support.AbstractApplicationContext prepareRefresh
信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@1a0b53e: startup date [Wed Oct 23 17:55:15 CST 2013]; root of context hierarchy
十月 23, 2013 5:55:16 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [applicationContext-aop.xml]
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [applicationContext-aop.xml]; nested exception is java.lang.NoClassDefFoundError: org/aopalliance/aop/Advice
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412)
at 一个关于jsp的基本有关问题