package com.gc.impl; import org.apache.log4j.Level; public interface TimeBookInterface { public void doAuditing(String name); //刚开始时,这里一直出错,后添加import org.apache.log4j.Level;OK! public void doCheck(String name); }
package com.gc.action; import com.gc.impl.TimeBookInterface; public class TimeBook implements TimeBookInterface{ public void doAuditing(String name) { System.out.println("审核数据的相关程序正在执行……"); } public void doCheck(String name) { System.out.println("财务关帐的相关程序正在执行……"); } }
package com.gc.action; import java.lang.reflect.Method; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.springframework.aop.MethodBeforeAdvice; public class LogBefore implements MethodBeforeAdvice { private Logger logger=Logger.getLogger(this.getClass().getName()); public void before(Method method,Object[]args,Object target)throws Throwable { logger.log(Level.INFO,args[0]+"开始审核数据……"); } }
package com.gc.action; import java.lang.reflect.Method; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.springframework.aop.AfterReturningAdvice; public class LogAfter implements AfterReturningAdvice { private Logger logger=Logger.getLogger(this.getClass().getName()); public void afterReturning(Object object,Method method,Object[]args,Object target)throws Throwable { logger.log(Level.INFO,args[0]+"审核数据结束……"); } }
HelloWorld .*do.* .*do.*
package com.gc.test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.FileSystemXmlApplicationContext; import com.gc.impl.FinanceInterface; import com.gc.impl.TimeBookInterface; public class TestHelloWorld { public static void main(String args[]) //throws InstantiationException,IllegalAccessException,ClassNotFoundException { ApplicationContext actx=new FileSystemXmlApplicationContext("config.xml"); TimeBookInterface timeBookProxy=(TimeBookInterface)actx.getBean("timeBook"); timeBookProxy.doAuditing("张三"); } }
package com.gc.test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.FileSystemXmlApplicationContext; import com.gc.impl.FinanceInterface; import com.gc.impl.TimeBookInterface; public class TestHelloWorld { public static void main(String args[]) //throws InstantiationException,IllegalAccessException,ClassNotFoundException { ApplicationContext actx=new FileSystemXmlApplicationContext("config.xml"); TimeBookInterface timeBookProxy=(TimeBookInterface)actx.getBean("timeBook"); timeBookProxy.doCheck("张三"); } }
HelloWorld <!-- --> .*doCheck.* .*doAuditing.*
package com.gc.test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.FileSystemXmlApplicationContext; import com.gc.impl.FinanceInterface; import com.gc.impl.TimeBookInterface; public class TestHelloWorld { public static void main(String args[]) //throws InstantiationException,IllegalAccessException,ClassNotFoundException { ApplicationContext actx=new FileSystemXmlApplicationContext("config.xml"); TimeBookInterface timeBookProxy=(TimeBookInterface)actx.getBean("timeBook"); timeBookProxy.doCheck("张三"); } }
package com.gc.test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.FileSystemXmlApplicationContext; import com.gc.impl.FinanceInterface; import com.gc.impl.TimeBookInterface; public class TestHelloWorld { public static void main(String args[]) //throws InstantiationException,IllegalAccessException,ClassNotFoundException { ApplicationContext actx=new FileSystemXmlApplicationContext("config.xml"); TimeBookInterface timeBookProxy=(TimeBookInterface)actx.getBean("timeBook"); timeBookProxy.doAuditing("张三"); } }Invalid property 'pattens' of bean class [org.springframework.aop.support.RegexpMethodPointcutAdvisor]: Bean property 'pattens' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?