目的: 以SpringBoot项目为基础,定义写入日志注解@InsertLog,当项目启动了访问controller时,在标注了注解@InsertLog的controller方法上,将会执行“写入日志到数据库”操作;
实现:定义切面LogAspect,实现自定义注解的生效;
一、环境准备
开发工具: IntelliJ IDEA 2018.2.3 x64
JDK版本: 1.8
Maven版本: apache-maven-3.5.0
Spring Boot : (v2.1.0.RELEASE)
二、创建SpringBoot项目aspect_log_demo
第1步、项目目录结构 ![](https://img-blog.csdnimg.cn/2019012516532148.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L1RoaW5raW5nY2Fv,size_16,color_FFFFFF,t_70)
第2步、新建注解包名com.thinkingcao.annotation,定义注解@InsertLog
package com.thinkingcao.annotation;
import java.la