SpringBoot 系列教程(十九):基于SpringBoot自定义注解和AOP实现日志记录

目的: 以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步、项目目录结构     

 第2步、新建注解包名com.thinkingcao.annotation,定义注解@InsertLog

package com.thinkingcao.annotation;

import java.la

猜你喜欢

转载自blog.csdn.net/Thinkingcao/article/details/86615088