?????????????????AOP
???????????AOP????? AspectJ ?????????????·????????
????1. ??????@Aspect????????????棬???????ж????????(@Pointcut)????????(@Before?? @AfterReturning??@After??@AfterThrowing??@Around).
????2. ????????????????
????3. ???????????xml?У????????????????????????Bean????????????????????Spring AoP?????????
??????????????? aspectJ ?? jar ???? aspectjweaver.jar aspectjrt.jar
?????????
User.java
package com.bjsxt.model;
public class User {
private String username;
private String password;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
/**
*?????
*/
package com.bjsxt.dao;
import com.bjsxt.model.User;
public interface UserDAO {
public void save(User user);
}
??????????
????package com.bjsxt.dao.impl;
????import org.springframework.stereotype.Component;
????import com.bjsxt.dao.UserDAO;
????import com.bjsxt.model.User;
????@Component("u")
????public class UserDAOImpl implements UserDAO {
????public void save(User user) {
????System.out.println("user save11d!");
????/*throw new RuntimeException("exception");*/ //????
????}
????}