spring AOP切面日志
导入依赖
<properties>
<fastjson.version>1.2.49</fastjson.version>
</properties>
<!-- spring-boot aop依赖配置引入 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>${
fastjson.version}</version>
</dependency>
文件目录
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/982ea994374874d44a476a1a156bfffd.png#pic_center)
切面日志可以自己创建注解,也可以不创建注解,我写的是创建注解的。
创建注解
@Documented
@Target({
ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface OperationLogDetail {
String detail() default "";
int level() default 0;
OperationType operationType() default OperationType.UNKNOWN;
OperationUnit operationUnit() default OperationUnit.UNKNOWN;
}
dao层
public class OperationLog {
private String id;
private Date createTime;
private Integer level;
private String operationUnit;
private String method;
private String args;
private String userId;
private String userName;
private String describe;
private String operationType;
private Long runTime;
private String returnValue;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Integer getLevel() {
return level;
}
public void setLevel(Integer level) {
this.level = level;
}
public String getOperationUnit() {