参考文章:如何优雅的设计后台操作日志?_操作日志表设计-优快云博客
记录下踩的坑:
1.参考文章用的是后置通知@AfterReturning,我想用环绕通知@Around,发现切点方法日志未打印,是通过idea提示:Pointcut methods should have empty body。发现这里日志不生效。
2.当前项目是maven+微服务,单独模块代码路径和微服务代码路径不一致,微服务引入该模块时需要使用@ComponentScan重新指定扫描本项目路径和该模块路径,麻烦。在单独模块中进行扫描:
@Configuration // basePackages配置单独模块的代码路径 @ComponentScan(basePackages = {"com.sss.bbb"}) public class ComponentConfig { }
单独模块创建resources/META-INF/spring.factories 文件,配置:
org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.sss.config.ComponentConfig