aopaspect区别_Spring AOP和AspectJ AOP的区别对比

Spring面试题关于Spring AOP和AspectJ AOP的区别对比,Spring AOP属于运行时增强,AspectJ属于编译时增强,Spring AOP和AspectJ AOP适用场景等,面试题吧分享Spring AOP和AspectJ AOP的区别对比:

Spring AOP和AspectJ AOP的之间有哪些区别?

AOP即面向切面编程(Aspect Oriented Program),AOP将重复的代码从业务逻辑中剥离出来,独立封装成一个类和若干方法,剥离出来的类和方法称为横切逻辑和增强,剥离后的业务逻辑的类和方法称为目标逻辑,剥离的位置称为切点。

AOP是Spring框架面向切面的编程思想,Spring AOP属于运行时增强,AspectJ 是编译时增强,Spring AOP基于代理(Proxying),而AspectJ基于字节码操作(Bytecode Manipulation)。Spring AOP集成AspectJ,AspectJ是Java生态系统中很完整的AOP框架。AspectJ相比于Spring AOP功能更强大,Spring AOP相对来说更简单一些。

切面比较少的情况下Spring AOP和AspectJ AOP的性能区别不大,当切面较多时性能区别就体现出来了,AspectJ要比Spring AOP快很多。

关于Spring AOP和AspectJ AOP的区别可以参考下表:

Spring AOP

AspectJ AOP

在Java中实现

使用Java编程语言的扩展实现

不需要单独的编译过程

需要AspectJ编译器(ajc),设置LTW不需要

使用运行时织入

你可能感兴趣的:(aopaspect区别)