我正在看书,里面的代码如下:package com.java.chapter23;import org.aspectj.apache.bcel.classfile.Method;
import org.springframework.aop.MethodBeforeAdvice;public class BeforeAdvice1 implements MethodBeforeAdvice { <--出错行
public void before(Method method, Object[] args , Object target) throws Throwable {
System.out.println("before Advice:" + target.getClass().getName() + "." + method.getName() + " 参数值:" + args[0]);
if (method.getName().equals("getHello")) {
args[0] = "超人";
}
}
}提示BeforeAdvice1那里出错,提示如下:
The type BeforeAdvice1 must implement the inherited abstract method
MethodBeforeAdvice.before(Method, Object[], Object)
请问为什么?谢谢
import org.springframework.aop.MethodBeforeAdvice;public class BeforeAdvice1 implements MethodBeforeAdvice { <--出错行
public void before(Method method, Object[] args , Object target) throws Throwable {
System.out.println("before Advice:" + target.getClass().getName() + "." + method.getName() + " 参数值:" + args[0]);
if (method.getName().equals("getHello")) {
args[0] = "超人";
}
}
}提示BeforeAdvice1那里出错,提示如下:
The type BeforeAdvice1 must implement the inherited abstract method
MethodBeforeAdvice.before(Method, Object[], Object)
请问为什么?谢谢
import org.springframework.aop.*;
import java.lang.reflect.*;
import java.lang.reflect.Method;import org.springframework.aop.MethodBeforeAdvice;public class BeforeAdvice1 implements MethodBeforeAdvice {
@Override
public void before(Method method, Object[] args, Object target)
throws Throwable {
// TODO Auto-generated method stub
System.out.println("before Advice:" + target.getClass().getName() + "."
+ method.getName() + " 参数值:" + args[0]);
if (method.getName().equals("getHello")) {
args[0] = "超人";
}
}
}