Java:自定义注解实现日志记录

SpringBoot+AOP+自定义注解,优雅实现日志记录 AOP切面编程+自定义注解,优雅记录系统日志 阅读详情

前言:自定义注解的魅力

在Java开发中,注解(Annotation)是一种强大的元数据形式,它能够为程序元素(如类、方法、变量等)提供附加信息。自定义注解允许我们根据需要创建特定用途的标签,从而实现特定功能,比如日志记录、权限控制等。通过自定义注解来记录日志,可以让我们的代码逻辑更加专注于业务本身,而将日志记录这样的横切关注点从业务代码中分离出来。

目标:实现一个简单的日志记录注解

我们的目标是创建一个名为@SysLog的自定义注解,它可以应用于任何方法上,当这个方法被调用时,自动记录下方法的执行信息,如方法名、参数值和执行时间。为了实现上述目标,我采用的方案是:自定义注解@SysLog与Spring AOP技术结合,根据MyBatis不同操作类型(增删改查)来实现日志记录,将日志信息保存到数据库中。

废话不多说,上代码!

步骤1:定义日志类型枚举

首先,创建一个枚举类LogTypeEnum来定义日志的操作类型,方便后续日志记录的扩展。

public enum LogTypeEnum {
    INSERT("INSERT", "新增"),
    UPDATE("UPDATE", "更新"),
    DELETE("DELETE", "删除"),
    QUERY("QUERY", "查询");

    private String code;
    private String description;

    LogTypeEnum(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }
}
步骤2:创建日志数据库表

我们需要在数据库中创建一个日志表来存放日志信息。

CREATE TABLE `sys_log` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `operate_type` VARCHAR(2) NOT NULL COMMENT '操作类型代码',
  `operate_content` varchar(999) NOT NULL COMMENT '操作内容',
  `operate_time` datetime NOT NULL COMMENT '操作时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
步骤3:定义实体类SysLog

创建一个SysLog实体类来映射上述数据库表。

@Data
public class SysLog {
    private Long id;
    private String operateType; // 操作类型
    private String operateContent; // 操作内容
    private LocalDateTime operateTime; // 操作时间
}
步骤4:定义Mapper接口

创建SysLogMapper接口来定义MyBatis操作SQL。

public interface SysLogMapper {
    void insertLog(SysLog sysLog);
}

对应的mapper.xml文件(SysLogMapper.xml)中的SQL插入语句:

<insert id="insertLog">
    INSERT INTO sys_log (operate_type, operate_content, operate_time)
    VALUES (#{operateType}, #{operateContent}, #{operateTime})
</insert>
步骤5:定义自定义注解@SysLog

定义@SysLog注解,允许指定操作类型,并提供一个默认值。

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface SysLog {
    // 操作类型,默认为查询
    String value() default "QUERY";
}
步骤6:实现日志记录切面

为了在注解标记的方法执行前后自动记录日志,我们将使用AspectJ(面向切面编程)来拦截这些方法调用。首先,确保你的项目中已经引入了AspectJ相关的依赖。

接下来,创建一个切面类,用于实现日志记录逻辑:

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * 日志记录切面类
 */
@Aspect
@Component
public class SysLogAspect {
    @Autowired
    private SysLogMapper sysLogMapper;

    /**
     * 环绕通知,用于拦截带有@SysLog注解的方法
     *
     * @param joinPoint 切入点对象
     * @param sysLog    注解对象,包含操作类型信息
     * @return 原方法执行结果
     * @throws Throwable 抛出异常
     */
    @Around("@annotation(sysLog)")
    public Object around(ProceedingJoinPoint joinPoint, SysLog sysLog) throws Throwable {
        long startTime = System.currentTimeMillis();
        Object result;
        try {
            result = joinPoint.proceed(); // 执行原方法
        } catch (Throwable throwable) { // 捕获方法执行中抛出的异常
            handleLog(joinPoint, sysLog, startTime, throwable.getMessage(), true);
            throw throwable;
        }
        handleLog(joinPoint, sysLog, startTime, null, false); // 方法正常执行完毕后的日志处理
        return result;
    }

    /**
     * 处理日志记录逻辑
     *
     * @param joinPoint      切入点对象
     * @param sysLog         注解对象,包含操作类型信息
     * @param startTime      方法开始执行的时间
     * @param errorMsg       错误信息,如果有异常则传入异常信息
     * @param isError        是否为错误日志
     */
    private void handleLog(ProceedingJoinPoint joinPoint, SysLog sysLog, long startTime, String errorMsg, boolean isError) {
        String className = joinPoint.getTarget().getClass().getSimpleName();
        String methodName = joinPoint.getSignature().getName();
        LocalDateTime operateTime = LocalDateTime.now();
        String contentBase = String.format("类名:%s,方法名:%s,操作类型:%s", className, methodName, sysLog.value().getDescription());

        String content = isError ? contentBase + ",异常信息:" + errorMsg : contentBase;

        SysLog log = new SysLog();
        log.setOperateType(sysLog.value());
        log.setOperateContent(content);
        log.setOperateTime(operateTime);
        sysLogMapper.insertLog(log);
    }
}

步骤7:在Controller中使用@SysLog

接下来,我们将在一个示例Controller中展示如何使用@SysLog注解。

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {

    @GetMapping("/users")
    @SysLog(value = LogTypeEnum.QUERY.getCode()) // 使用枚举的getCode()方法获取字符串值
    public String getUsers() {
        // 查询用户逻辑
        return "获取用户列表";
    }

    @PostMapping("/users")
    @SysLog(value = LogTypeEnum.INSERT.getCode())
    public String createUser(User user) {
        // 创建用户逻辑
        return "创建用户成功";
    }

    // 更多操作...
}

总结

通过以上步骤,我们不仅定义了自己的日志记录注解@SysLog,还实现了它的自动拦截逻辑,使得日志记录变得简单而高效。这种方法的优势在于它将日志记录逻辑从业务代码中分离,提高了代码的可读性和可维护性。现在,每当方法被调用,相关日志就会自动被记录下来,无需在业务代码中手动插入日志语句,极大地提升了开发效率和代码的整洁度;并且这种方式保持了代码的灵活性,同时也保留了枚举作为操作类型的标准化定义,便于理解和维护。

希望这篇教程对你有所帮助,动手实践一下,感受自定义注解和AOP带来的便利!

Java基于注解实现日志记录模块,超详细注释! 在项目开发过程中,日志记录是一个至关重要的环节,它能够帮助开发人员追踪用户的重要操作,如新增、删除、修改等,从而有效监控系统的运行状态。通过日志记录,我们可以深入了解系统的运行情况,及时发现并解决问题,优化性能,提高用户体验。 阅读详情

相关推荐

JAVA 使用自定义注解实现插入日志操作功能

目录1、新建数据库表:操作日志记录表 2、创建Entity实体类3、创建Annotation注解4、创建AOP切面类5、注解使用方法

H_bbo的博客 3586

自定义注解实现日志操作

aop实现操作日志,并利用事件监听实现异步操作日志,保存到数据库

newstudent_的博客 1464

Java自定义日志模块实现

自定义日志模块(接口及代理实现),而不直接使用第三方日志框架接口,避免在日志框架升级或者切换时,代码过多耦合。 这个举例说明一下: 比如,在某一项目开始时使用的是“log4j”框架,后面经过研究发现“sf4j”框架功能更强大,想切换到“sf4j”。常规的做法是,修改项目中每一处调用到“log4j”相关模块的代码。如果是项目比较大,所要花费的工作量也真不少,但如果使用了上面的方式,则只需要实现“LoggerAdapter”接口,使之与具体的日志(logger)进行适配,并且(如果必要)重写或者调整LoggerAdapterFacory类即可。 注意:代码使用的是utf-8编码

JAVA自定义注解记录操作日志

JAVA自定义注解记录操作日志

m0_52767002的博客 3200

如何让Arduino IDE支持你手里的STM32 nucleo开发板

Arduino IDE开发环境在默认情况下不支持STM32 NUCLEO开发板,只有通过添加附加开发板管理包才能使用。目前为止,只有一部分板子支持使用Arduino IDE开发环境进行开发,分别是 Nucleo F207ZG, Nucleo F429ZI, Nucleo F030R8, Nucleo F091RC, Nucleo F103RB, Nucleo F303RE, Nucl...

mzw72188552的专栏 8979

浅谈专项测试之弱网络测试

浅谈专项测试之弱网络测试 一.弱网络测试背景 移动端产品的使用并非完全都是在流畅的wifi环境,大部分用户主要使用4G,3G,2G等网络,另外因为移动端产品使用的场景多变,如进公交,上地铁,坐电梯,使得弱网测试显得尤为重要。考虑到各种场景的客户端展示及容错,提升产品的印象和用户体验,提高产品的健壮性,弱网测试必不可少。 二.弱网络测试建议 网下需要进行功能点测试,无网络测试,网络切换测试等,测试过程除了关注功能点的实现,还应关注用户体验等各个方面 三.弱网络测试通用功能点总结 四.弱网络测试用例实例

ITstudy001的博客 1019

spring -AOP与自定义注解

AOP的使用有两种 1 使用自定义注解 思路: 创建自定义注解 @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface Log { String value() default ""; } 创建切面类,在切面类定义切点和通知注解 @Aspect @Component public class LogAsPect { private final static Logger lo

Qfoom的博客 293

5分钟搞定!用Cursor和.NET 9.0快速搭建串口通讯上位机(附VS Code插件配置)

本文分享了如何利用Cursor AI编程助手与.NET 9.0,在5分钟内快速构建一个功能完整的串口通讯上位机程序。通过自然语言描述需求,AI自动生成WinForms界面和核心代码,极大提升了硬件调试工具的定制开发效率。文章详细介绍了环境配置、AI协作编码、功能实现与调试的全过程。

weixin_28366353的博客 293

spring boot自定义注解(1)—实现自定义操作日志注解

varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT ‘请求是否成功’,varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT ‘请求名’,// logRecordEntity.setId(request.getRemoteHost());//注解信息中的 module的内容。

城南蝈蝈 709

(Python基础教程之二)在Sublime Editor中配置Python环境

Python基础教程 在SublimeEditor中配置Python环境 Python代码中添加注释 Python中的变量的使用 Python中的数据类型 Python中的关键字 Python字符串操作 Python中的list操作 Python中的Tuple操作 Pythonmax()和min()–在列表或数组中查找最大值和最小值 Python找到最大的N个(前N个)或最小的N个项目 Pyth...

novelly的专栏 2328

【Java核心技术_二十七】Java 自定义注解+Spring AOP 实现统一日志记录功能

想象一下,你正在写一本日记,你可以在某些页面上贴上彩色的便签,上面写着一些关键词或者提醒。在 Java 中,注解就像是这些便签,它可以贴在类、方法、变量等程序元素上,为它们添加额外的信息。 注解本身不会改变程序的运行逻辑,但它们可以被其他工具或者框架读取和处理。比如,编译器可以根据注解来检查代码的正确性,或者框架可以根据注解来自动配置对象。

技术管理修行 1607

002、搭建你的第一个Agent开发环境:Python与核心库安装

在上一篇《Agent智能体开发入门:概念、应用与前景》中,我们描绘了Agent智能体的宏伟蓝图,理解了其作为“数字员工”的巨大潜力。然而,许多开发者在迈出第一步时,常常被复杂的依赖、版本冲突和晦涩的配置所劝退,空有想法却无从下手。这种感觉就像拿到了一张藏宝图,却找不到出发的港口。本文正是你的“启航指南”。我们将彻底解决这个痛点,通过一个清晰、可复现的流程,为你搭建一个专为Agent开发量身定制的Python环境。一个纯净、隔离的Python虚拟环境,避免项目间的“依赖地狱”。一套经过验证的核心工具链。

G_RE_RE的博客 116

Java自定义注解

注解分类(根据Annotation是否包含成员变量,可以把Annotation分为两类):标记Annotation:没有成员变量的Annotation;这种Annotation仅利用自身的存在与否来提供信息元数据Annotation:包含成员变量的Annotation;它们可以接受(和提供)更多的元数据;

weixin_67450855的博客 1万+

ESP32-C3第二路串口(非调试)串口打通(1)

ESP32-C3第二路串口(非调试)串口打通(1)

phmatthaus的专栏 2663

基于分水岭分割进行肺癌诊断

近年来,肺癌的发病率和病死率均迅速上升,目前已居所有癌症之首。随着肺癌病人数量的增加,医生对肺部 CT 图像进行研判的工作量也增加了不少,在这种情况下难免工作效率降低甚至会出现误诊。为了帮助医生减少重复性工作,对肺部 CT 图像进行计算机辅助检测的技术就被广泛应用于对肺癌的诊断和治疗过程中。医学 CT 图像处理主要是研究医学图像中的器官和组织之间的关系,并进行病理性分析。

在职AI算法工程师,擅长计算机视觉,YOLO目标检测、分割等,擅长web、pyqt界面可视化,好内容持续更新中,来这里跟大家一起学习,共同进步 1575

自定义注解-aop实现日志记录

关于注解,平时接触的可不少,像是 @Controller、@Service、@Autowried 等等,不知道你是否有过这种疑惑,使用 @Service 注解的类成为我们的业务类,使用 @Controller 注解的类就成了请求的控制器,使用 @Autowried 注解的类就会帮我们实现自动注入… 以前,我们只知道使用注解,今天我们要手写一个注解。 一、以日志记录为例 在没有使用注解实现记录日志之...

niceyoo的博客 4447

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Java自定义注解实现日志记录

教你怎么使用自定义注解记录日志

yehongzhi1994的博客 3315

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

SpringAop(自定义注解)实现用户操作日志记录

1.简介 在使用spring完成项目的时候需要完成记录日志,开始以为Spring 的AOP功能,就可以轻松解决,半个小时都不用,可是经过一番了解过后,发现一般的日志记录,只能记录一些简单的操作,例如表名、表名称等记录不到。 这个时侯就用到了自定义注解,把想要记录的内容放在注解中,通过切入点来获取到注解参数,然后将参数插入数据库记录 2.Spring AOP 2.1.关于Spring AOP的一些术语 切面(Aspect):在Spring AOP中,切面可以使用通用类或者在普通类中以@Aspec

gp_911014的博客 5105

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

Springboot中自定义注解,实现日志记录

Springboot自定义注解分了两个部分1.定义注解,2.Aop实现注解

qq_42867665的博客 1万+

Java自定义注解、Spring AOP、使用AOP实现和自定义注解实现日志记录

Java自定义注解以及Spring的AOP详解,通过AOP和自定义注解实现日志记录

suiyishiguang的博客 2662

Spring AOP实现复杂的日志记录(自定义注解)

前段时间做项目中,业务逻辑要求只要对数据库数据进行改动的都需要记录日志(增删改),记录的内容有操作者,操作的表名及表名称,具体的操作,以及对那条数据进行操作。当时想到的就是Spring 的AOP功能。

小草的博客 2万+

java 自定义注解+AOP实现日志记录

java 自定义注解+AOP实现日志记录 1、自定义注解 注解:参考我的这篇博客:https://blog.csdn.net/xiaoao20080/article/details/89632015 package com.xxx.controller.framework.auth; import java.lang.annotation.*; @Target({ ElementT...

Object的博客 2097

springboot 自定义注解+AOP 实现日志记录

      一.自定义注解   package com.xiaojukeji.common.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import j...

全冉 的博客 1万+

java注解详解及自定义注解实现

java注解详解及自定义注解实现

qq_43418737的博客 5509
上一篇: Java:防止重复提交订单
下一篇: Spring Boot与Spring Security结合MyBatis构建安全的RESTful Web服务
我的天呐不会吧
博客等级 码龄8年 165粉丝 9原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值