HI,
my problem is as follows :
I want to use annotition in my project,but it does not work with AOP,
The code :
//
public interface Dao {
public void test();
}
//
@Component("dao")
public class DaoImpl implements Dao {
public void test() {
System.out.println("just a test");
}
}
//
@Aspect
public class TestIntercepor {
@Pointcut("execution(* com.pkg.dao.impl.*.*(..))")
public void allDaoIMpl(){};
@Before("allDaoIMpl()")
public void check(JoinPoint jp){
System.out.println(jp.getTarget().getClass().getNa me());
}
}
@Controller
public class UserController {
@Resource(name = "dao")
private Dao dao;
@RequestMapping("test")
public String areaList(Model model){
dao.test();
return "";
}
}
when I use @component("dao") on the implemention class ,the aop does not
work,but if I define <bean id="dao" class="com.pkg.dao.impl.DaoImpl"/> in the xml file ,it works well.
Help me please,many thanks!


Reply With Quote
