SpringAOP02_1

SpringAOP详解+快速入门 本文介绍了 Spring AOP 的实现原理,并通过实例解析详细阐述了其实现过程。在使用 Spring AOP时,我们需要定义切面类,并为需要实现AOP的方法添加注解。 Spring 会自动将切面逻辑插入到这些方法中,从而实现AOP的功能。 阅读详情

AOP实现日志切入

AOP:(Aspect Oriented Programming)面向切面编程;
OOP:(Object Oriented Programming )面向对象编程;

面向切面编程:基于OOP基础之上新的编程思想;
指在程序运行期间,将某段代码动态的切入到指定方法的指定位置进行运行的这种编程方式,面向切面编程;

场景:计算器运行计算方法的时候进行日志记录;
加日志记录:
1)、直接编写在方法内部;不推荐,修改维护麻烦;

  日志记录:系统的辅助功能;
  业务逻辑:(核心功能)
  耦合;

2)、我们希望的是;
业务逻辑:(核心功能);日志模块;在核心功能运行期间,自己动态的加上;
运行的时候,日志功能可以加上;
可以使用动态代理来将日志代码动态的在目标方法执行前后先进行执行;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Arrays;

import com.atguigu.inter.Calculator;
import com.atguigu.utils.LogUtils;

/**
 * 帮Calculator.java生成代理对象的类
 * Object newProxyInstance
 * (ClassLoader loader, Class<?>[] interfaces, InvocationHandler h)
 *
 * @author lfy
 *
 */
public class CalculatorProxy {

    /**
     * 为传入的参数对象创建一个动态代理对象
     * @param calculator
     * @return
     *
     * Calculator calculator:被代理对象;(宝宝)
     * 返回的:宋喆
     */
    public static Calculator getProxy(final Calculator calculator) {
        // TODO Auto-generated method stub

        //方法执行器。帮我们目标对象执行目标方法
        InvocationHandler h = new InvocationHandler() {
            /**
             * Object proxy:代理对象;给jdk使用,任何时候都不要动这个对象
             * Method method:当前将要执行的目标对象的方法
             * Object[] args:这个方法调用时外界传入的参数值
             */
            @Override
            public Object invoke(Object proxy, Method method, Object[] args)
                    throws Throwable {
                
                //System.out.println("这是动态代理将要帮你执行方法...");
                Object result = null;
                try {
                    LogUtils.logStart(method, args);

                    // 利用反射执行目标方法
                    //目标方法执行后的返回值
                    result = method.invoke(calculator, args);
                    LogUtils.logReturn(method, result);
                } catch (Exception e) {
                    LogUtils.logException(method,e);
                }finally{
                    LogUtils.logEnd(method);

                }

                //返回值必须返回出去外界才能拿到真正执行后的返回值
                return result;
            }
        };
        Class<?>[] interfaces = calculator.getClass().getInterfaces();
        ClassLoader loader = calculator.getClass().getClassLoader();

        //Proxy为目标对象创建代理对象;
        Object proxy = Proxy.newProxyInstance(loader, interfaces, h);
        return (Calculator) proxy;
    }

}

jdk动态代理:
1)、写起来难;
2)、jdk默认的动态代理,如果目标对象没有实现任何接口,是无法为他创建代理对象的;


**Spring动态代理;**Spring实现了AOP功能;底层就是动态代理;
1)、可以利用Spring一句代码都不写的去创建动态代理;
实现简单,而且没有强制要求目标对象必须实现接口;
将某段代码(日志)动态的切入(不把日志代码写死在业务逻辑方法中)到指定方法(加减乘除)的指定位置(方法的开始、结束、异常。。。)进行运行的这种编程方式(Spring简化了面向切面编程)
AOP专业术语;
在这里插入图片描述

AOP使用步骤:
1、导包;

commons-logging-1.1.3.jar
spring-beans-4.0.0.RELEASE.jar
spring-context-4.0.0.RELEASE.jar
spring-core-4.0.0.RELEASE.jar

spring-expression-4.0.0.RELEASE.jar
Spring支持注解的包
spring-aop-4.0.0.RELEASE.jar

Spring支持面向切面编程的包是:

spring-aspects-4.0.0.RELEASE.jar:基础版
加强版的面向切面编程(即使目标对象没有实现任何接口也能创建动态代理)
com.springsource.net.sf.cglib-2.2.0.jar
com.springsource.org.aopalliance-1.0.0.jar
com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar

2、写配置;
1)、将目标类和切面类(封装了通知方法(在目标方法执行前后执行的方法))加入到ioc容器中
2)、还应该告诉Spring到底哪个是切面类@Aspect
3)、告诉Spring,切面类里面的每一个方法,都是何时何地运行;

@Before("execution(public int com.czl.impl.MyMathCalculator.*(int, int))")
public static void logStart(){
    System.out.println("【xxx】方法开始执行,用的参数列表【xxx】");
}

//想在目标方法正常执行完成之后执行
@AfterReturning("execution(public int com.czl.impl.MyMathCalculator.*(int, int))")
public static void logReturn(){
    System.out.println("【xxxx】方法正常执行完成,计算结果是:");
}

//想在目标方法出现异常的时候执行
@AfterThrowing("execution(public int com.czl.impl.MyMathCalculator.*(int, int))")
public static void logException() {
    System.out.println("【xxxx】方法执行出现异常了,异常信息是:;这个异常已经通知测试小组进行排查");
}

//想在目标方法结束的时候执行
@After("execution(public int com.czl.impl.MyMathCalculator.*(int, int))")
public static void logEnd() {
    System.out.println("【xxx】方法最终结束了");
}
   

4)、开启基于注解的AOP模式


<!--  开启基于注解的AOP功能;aop名称空间
	  当Spring IOC容器侦测到bean配置文件中的<aop:aspectj-autoproxy>元素时,
	  会自动为与AspectJ切面匹配的bean创建代理-->
<aop:aspectj-autoproxy></aop:aspectj-autoproxy>

5)、测试

@Test
	public void test() {
		
//		MyMathCalculator myMathCalculator = new MyMathCalculator();
//		myMathCalculator.add(2, 12);
        //因为切面类都在IOC容器中,所以直接new是不能使用IOC容器中的强大的方法的,需要从IOC容器中获取bean
        //有实现Calculator接口
		//1、从ioc容器中拿到目标对象;注意:如果想要用类型,一定用 他的接口类型,不要用它本类
		//细节一:打印得到的对象,com.atguigu.impl.MyMathCalculator@6c64cb25/ioc容器中的组件看似MyMathCalculator,
        // 但是实际上容器启动为MyMathCalculator创建的对象是一个代理对象class com.sun.proxy.$Proxy12,所以不能用本类MyMathCalculator.class从容器中获取,
        // 代理对象和目标对象(被代理对象)共同实现了接口,所以可以用接口获取代理对象//Calculator bean = ioc.getBean(Calculator.class);

		//AOP的底层就是动态代理,由于有了切面类,对于MyCalculator类,容器中保存的组件是他的代理对象;$Proxy12。
        // 而不是MyCalculator.class 所以不是本类的类型
		
		//Calculator bean = ioc.getBean(Calculator.class);
		//bean.add(2, 1);
		//System.out.println(bean);
		//System.out.println(bean.getClass());
		
		
		
		//Calculator bean2 = (Calculator) ioc.getBean("myMathCalculator");//若用id查找,当然可以直接类首字母小写查找
		//System.out.println(bean2.getClass());





        //没有实现Calculator接口
		//没有实现接口就是本类类型,此时IOC容器中存在的是
		//class com.atguigu.impl.MyMathCalculator$$EnhancerByCGLIB$$fe279f42   $$表示内部类
		//cglib帮我们创建好的代理对象
        //MyCalculator bean = ioc.getBean(MyCalculator.class);   //用本类查找
		MyMathCalculator bean = (MyMathCalculator) ioc.getBean("myMathCalculator");//若用id查找,当然可以直接类首字母小写查找
		bean.add(1, 2);
		System.out.println(bean.getClass());
		
		
	}

总结:
①要在Spring中声明AspectJ切面,只需要在IOC容器中将切面声明为bean实例。
②当在Spring IOC容器中初始化AspectJ切面之后,Spring IOC容器就会为那些与 AspectJ切面相匹配的bean创建代理。
③在AspectJ注解中,切面只是一个带有@Aspect注解的Java类,它往往要包含很多通知。
④通知是标注有某种注解的简单的Java方法。
⑤AspectJ支持5种类型的通知注解:
[1]@Before:前置通知,在方法执行之前执行
[2]@After:后置通知,在方法执行之后执行
[3]@AfterRunning:返回通知,在方法返回结果之后执行
[4]@AfterThrowing:异常通知,在方法抛出异常之后执行
[5]@Around:环绕通知,围绕着方法执行

SpringAOP在项目中的简单应用 SpringAOP在项目中的简单应用   一、前言   项目背景 由于公司的机房到期,需要做应用迁移(包括数据库),割接到云平台。但是又不能进行一次性割接,需要分三个阶段:第一阶段割接2个地市,第二阶段再割接9个地市,第三阶段做全盘割接。在第一、第二阶段是要保证云平台与现网平台的应用能够正常并行运行。所以,要保证两边数据访问的正常,需要对某些功能进行改造。比如,某个子功能在并行阶段是不做... 阅读详情

相关推荐

RYU+Mininet的SDN架构-设计校园网络(一)

现有一个中学,需要设计一个中小型网络满足学校的网络需求。学校有教学区,实验室区域和服务器区域。教学区为了满足接入的灵活性和信号强度要求,需要满足设计WIFI满足日常教室和同学需求,接入上限为200人。实验室区域需要有一台教师主机方便管理实验室其余电脑,并且教师主机可以访问学校服务器,方便为同学们实验室授课。学校服务器区域设有学校相关重要文件和学校网页相关内容。最后学校还会接入互联网。

weixin_53284122的博客 8041

SpringAOP学习--SpringAOP简介及原理

前文对AOP做了介绍,实际项目中,一般不会直接上手手动实现aop,而是使用一些高级封装的aop实现,如SpringAOP。 Spring是一个广泛应用的框架,SpringAOP则是Spring提供的一个标准易用的aop框架,依托Spring的IOC容器,提供了极强的AOP扩展增强能力,对项目开发提供了极大地便利。 前文提到AOP的实现有AspectJ、JDK动态代理、CGLIB动态代理,SpringAOP不是一种新的AOP实现,其底层采用的是JDK/CGLIB动态代理。 JDK动态代理回顾 上一篇简单介绍了

u012098021的博客 6万+

Matlab子图排版终极指南:从tight_subplot到tiledlayout的实战对比

本文深入对比Matlab中两大子图排版工具:社区经典函数tight_subplot与官方现代布局管理器tiledlayout。针对默认subplot产生的子图间距与边缘距离问题,详细解析两者的设计哲学、参数控制与实战应用,帮助用户根据版本与需求选择最佳方案,实现高效、精确且美观的多子图排版。

weixin_29048309的博客 366

SpringAOP是啥,怎么用?

SpringAOP是啥,怎么用? 一、面试问题:什么是SpringAOP? SpringAOP的全称是(Aspect Oriented Programming)中文翻译过来是面向切面编程,个人理解:主要意思是我们的传统架构至上而下,后期想要从中间切入写代码添加功能,比如日志、权限、事务等,这时候我们就需要写使用代理模式写,而springaop就是专门把这一块写代码的地方给抽象了出来称为切面,从而解决的代码混乱的问题,它的底层实现也是基于代理模式(动态代理)完成的。 二、SpringAOP的应用场景有

Object_de_Father的博客 19万+

海思Hi3061M MCU:为高速吹风筒市场注入智能动力

此外,海思还提供了丰富的软件开发工具和生态环境组件,帮助开发者快速实现复杂功能。高速吹风筒因其高效的风力和快速的干燥效果,近年来在市场上越来越受欢迎。然而,传统的高速吹风筒在性能、噪音和使用寿命等方面仍有改进的空间。凭借其高性能、低功耗、低噪声和易用的开发工具,为高速吹风筒市场带来了全新的解决方案。这不仅提高了用户的使用体验,还延长了电机的使用寿命。这不仅减少了电机的电磁噪声,还提高了电机的运行效率。还支持风机顺逆风启动适配多种电阻范围的电机,进一步提高了吹风筒的适用性和灵活性。

2401_83448585的博客 2023

【2024年5月备考新增】《2024高项论文精华版(5)项目工作绩效域和度量绩效域》

3、专注于工作过程和能力。③专注于工作过程和能力。1、制定有效的度量指标。2、度量内容及相应指标。3、展示度量信息和结果。4、管理沟通和参与。7、监督新工作和变更。①制定有效的度量指标。②度量内容及相应指标。③展示度量信息和结果。5、基于度量进行诊断。

Else 的博客 1274

SpringAop(1)

一种规则Pointcut 的作⽤就是提供⼀组规则 (使⽤ AspectJ pointcut expression language 来描述), 告诉程序对哪些⽅法来进⾏功能增强。也就是@Around后边的字符串,描述了在哪里进行切入。对哪些的方法进行功能增强。(告诉哪些能被连接成切面,哪些不能被连接成切面,哪些能被Aop认识到,就是寻找匹配项)。这是切面的设置以及切面的逻辑@Slf4j@Component@Aspect//作用的范围是TestController。

syx050403的博客 1192

防护装备穿戴检查:基于YOLOv8与UI界面的深度学习应用

通过结合YOLOv8模型与UI界面,本系统实现了防护装备穿戴检查的自动化。该系统能够快速识别工作人员是否正确佩戴了所需的防护装备,帮助提高安全管理水平。未来,随着技术的发展,防护装备穿戴检查系统将在更多领域得到应用,如工业现场、建筑工地等,实现更加精确和高效的实时监控。

YOLO 373

Day02 SpringAOP

/自定义注解 public @interface LogAnno {

qq_55921543的博客 187

8、音频运行时系统的架构设计

本文深入探讨了音频运行时系统的分层设计及其优势,包括逻辑层和物理层的功能划分。通过分层设计,开发者可以更轻松地管理和优化音频资源,确保其在不同平台上的高效运行。文章还介绍了平台适配与优化、错误处理与调试以及未来发展方向等内容,为开发者提供了宝贵的参考和指导。

juice的博客 466

Python 爬虫实战:Twitter 数据定向抓取(特定话题 + 用户推文爬取与分析)

在社交媒体研究、舆情监测和市场分析等领域,Twitter 数据具有极高的价值。本文将详细介绍如何使用 Python 构建一个完整的 Twitter 数据爬取系统,包括特定话题和用户推文的爬取与分析。我们将涵盖从认证到数据存储、清洗、分析和可视化的全流程。

u014481728的博客 1050

SpringAOP面向切面编程

介绍面向切面编程的思想(AOP),AOP的组成,SpringAOP的简单演示使用,SpringAOP基于动态代理的实现原理。

trong_ 的烂笔头 2545

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

SpringAOP超详细教学

SpringAOP 前言 我的这篇AOP博客有大量的图片和例子教会怎么使用AOP 配置那里如果没有学习Maven的话也别急 就是使用maven下载了jar包而已了 你完全可以自己手动导入 如果你有一些代码比如说 事务 或者 日志等操作 需要大量嵌入你的代码前后的话 那么无疑AOP是最好用的 AOP运行流程 : 首先调用前置通知(你可以认为最一开始初始的东西)-&amp;gt;你的逻辑代码(这里先不说环...

TheSevenSky 8514

深度学习工具包 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")

全球国家地区城市数据

MySQL全球国家地区城市数据报。。。。。。。。。。。。

springAOP

AOP是Aspect Oriented Programming(面向切面编程),切面是指某一特定问题,所以AOP也可以理解为面向特定方法编程。比如我们在用户登录时设置登录校验拦截器,就是对“登录校验”这一类问题的统一处理,所以拦截器是AOP的一种应用,而AOP是一种思想,拦截器就是AOP思想的一种实现。而Spring框架也实现了这种思想,提供了拦截器技术的相关接口。同样的,统一数据返回格式和统一异常处理,也是AOP思想的一种实现。

2202_75439262的博客 954

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

SpringAOP

简要介绍SpringAop的概念及其注解用法

山中一扶苏的博客 1032

Spring框架、02SpringAOP

AOP介绍AOP(Aspect Oriented Programming)面向切面编程编码过程中将各个辅助功能分开编写, 运行时再将其织入到核心代码中这种思想的实现技术是:动态代理(jdk、cglib)SpringAOP就是为了简化动态切入这部分操作,开发者只需要通过少量的声明式配置,就可以实现AOP的编程 Spring会根据被代理的类是否有接口自动选择代理方式:如果有接口,就采用jdk动态代理如果没接口,就采用cglib的方式AOP术语目标对象(Target) 被代理的对象。

2402_84667776的博客 1374

SpringAOP(1)

SpringAOP

weixin_61518137的博客 846

关于SpringAOP的详细介绍

关于springAOP的记录

IDEA_guo的博客 991

【springBoot】springAOP

如果其他类需要使用,需要把切点声明为public.使用时,类的全限定名称+切点名称 ==> 包+类名@Slf4j@Aspect@Component@After("com.example.aopdemo.aspect.AspectDemo.pt()")//前置通知log.info("执行AspectDemo1 doAfter……");

weixin_66409969的博客 1047

SpringAOP和AspectJ有什么关系 ?

✅作者简介:大家好,我是Leo,热爱Java后端开发者,一个想要与大家共同进步的男人😉😉✨特色专栏:🥭本文内容:SpringAOP和AspectJ有什么关系?📚个人知识库:,欢迎大家访问我们知道现在开发都是Spring,讲的最多的也是SpringAOP,在说springAOP前,先了解下AOP是什么?AOP是通过 “预编译方式” 和 “运行期间动态代理” 实现程序功能的统一维护的一种技术。

分享思想,留下痕迹。 1736

面试遇到SpringAOP不要慌

Aspect Oriented Programming(面向切面编程)是一种编程思想。所谓切面可以理解为特定的一些方法。所以AOP可以看成是面向特定的方法进行编程。比如上一篇文章提到的拦截器,就是AOP的体现。它针对特定的方法进行统一的管理,让代码模块化,易于维护。包括ExceptionAdvice、ResponseBodyAdvice(统一异常处理、统一数据返回格式)都运用了AOP的思想。定义一个注解:@Retention(RetentionPolicy.RUNTIME)//表示运行时,仍然存在。

HYY的博客 1217

springAOP落地实现

江湖阳哥曾经说过这么句话:使用技术在当前这个环境中无非就是这么几步:1、引入POM(maven)坐标2、改yml(配置文件也可以是properties等等)3、写配置类或者在启动类上加注解4、写代码就完事提示:以下是本篇文章正文内容,下面案例可供参考好了尽情的开发使用吧,其实这个是为了我写那个面试题的文章准备的哈哈哈哈。

sutingStart的博客 2129
上一篇: SpringIOC04
下一篇: SpringAOP01(动态代理的java实现)
cai_ing
博客等级 码龄9年 15粉丝 99原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值