spring boot 实现 AOP

切面配置
@Component @Aspect
public class HelloAspect { @Pointcut("execution(* com.educationtek.daoxue.controller.*.*(..))") public void pointCut() { } @Before("pointCut()") public void begin(){ System.out.println("开启事务"); } @After("pointCut()") public void close(){ System.out.println("关闭事务"); } }

业务逻辑
@RestController
@RequestMapping(value = "/api/hello")
public class HelloController {
@GetMapping("/aop")
public String printString(){
System.out.println("hello,Aop!");
return "hello,Aop";
}

}
程序输出

 

 

 

posted @ 2018-08-14 14:18  looyee  阅读(104)  评论(0编辑  收藏  举报