Spring Boot - Difference Between AOP and AspectJ Last Updated : 02 Mar, 2022 Comments Improve Suggest changes Like Article Like Report Spring Boot is built on the top of the spring and contains all the features of spring. And is becoming a favorite of developers these days because of its rapid production-ready environment which enables the developers to directly focus on the logic instead of struggling with the configuration and setup. Spring Boot is a microservice-based framework and making a production-ready application in it takes very little time. Following are some of the features of Spring Boot: It allows avoiding heavy configuration of XML which is present in springIt provides easy maintenance and creation of REST endpointsIt includes embedded Tomcat-serverDeployment is very easy, war and jar files can be easily deployed in the tomcat serverAOP Let's understand some terminologies: Aspect: The standalone distinct modules are called aspects. For example - the logging aspect.Join Points: This is a point where aspects can be injected to perform a specific task.Advice: It is the actual code block, which will be executed before or after the method execution.Pointcut: It is a set of one or more join points where the actual code will get executed. Pointcuts are specified using expression or patterns. See the following example: Java @Aspect public class LoggingAspectPointCutExample{ @PointCut("execution(*java11.fundamentals.*.*(...))") private void logData() {} } In the above example, we have used a few annotations. Let us understand their meanings. @Aspect: This annotation specifies that the class contains advice methods@PointCut: This annotation specifies the JoinPoint where advice should be executed.execution (*java11.fundamentals.*.*(..)): This specifics on which methods the given advice should be applied Introduction: This enables the inclusion of new methods, fields, or attributes to the existing classes. It is also known as inter-type declarations in AspectJ. In other words, with an introduction, an aspect can assert advised objects to implement a specific interface. It can also provide an implementation of this interface.Target object: It specifies the object that is being advised by one or more aspects. This object will always be a proxied object as Spring AOP is implemented using runtime proxies. AOP proxy: It denotes the object to implement the aspect contracts.Weaving: It is a process to create an advised object by linking one or more aspects with other objects or application types. There are various ways it can be done such as compile, load, or runtime. Spring AOP performs wearing at runtime.AspectJ AspectJ refers to a style of declaring aspects as regular Java classes annotated with annotations. Spring interprets the same annotations as AspectJ 5, using a library supplied by AspectJ for pointcut parsing and matching. The AOP runtime is still pure Spring AOP though, and there is no dependency on the AspectJ compiler or weaver. Difference Between AOP and AspectJSpring AOP AspectJ AOP It is not intended as a complete AOP solution – it can only be applied to beans that are managed by a Spring container.AspectJ is the original AOP technology that aims to provide a complete AOP solution.It makes use of runtime weaving.It makes use of three different types of weaving: Compile-time weaving, Post-compile weaving, Load-time weaving. It is a proxy-based AOP framework. This means that to implement aspects to the target objects, it'll create proxies of that object. This is achieved using either of two ways: JDK dynamic proxy, CGLIB proxy. On the other hand, this doesn't do anything at runtime as the classes are compiled directly with aspects. And so unlike Spring AOP, it doesn't require any design patterns. It is much slower than AspectJ. It has better performance.It is easy to learn and apply.It is more complicated than Spring AOP. Comment More infoAdvertise with us Next Article Spring Boot - Difference Between AOP and AspectJ R ridhi9697 Follow Improve Article Tags : Java Practice Tags : Java Similar Reads Spring Boot - Create a Custom Auto-Configuration Usually, we might be taking a maven project or grade project for Spring Boot related projects. We will be adding the dependencies in pom.xml (in case of a maven project). In a spring application, Spring Boot auto-configuration helps to automatically configure by checking with the jar dependencies th 4 min read Spring Boot - Consume Message Through Kafka, Save into ElasticSearch, and Plot into Grafana In this article, we are going to make a program to produce some data using Kafka Producer which will consume by the Kafka Consumer and save into the elastic search DB, and later on, plot that JSON data into the Grafana dashboard. Start with configuring all the required software and tool. Requirement 7 min read How to Implement AOP in Spring Boot Application? AOP(Aspect Oriented Programming) breaks the full program into different smaller units. In numerous situations, we need to log, and audit the details as well as need to pay importance to declarative transactions, security, caching, etc., Let us see the key terminologies of AOP Aspect: It has a set of 10 min read Spring Boot - AOP(Aspect Oriented Programming) The Java applications are developed in multiple layers, to increase security, separate business logic, persistence logic, etc. A typical Java application has three layers namely they are Web layer, the Business layer, and the Data layer. Web layer: This layer is used to provide the services to the e 4 min read Spring Boot - Cache Provider The Spring Framework provides support for transparently adding caching to an application. The Cache provider gives authorization to programmers to configure cache explicitly in an application. It incorporates various cache providers such as EhCache, Redis, Guava, Caffeine, etc. It keeps frequently a 6 min read Spring Boot - AOP Around Advice Aspect-oriented programming(AOP) as the name suggests uses aspects in programming. It can be defined as the breaking of code into different modules, also known as modularisation, where the aspect is the key unit of modularity. Aspects enable the implementation of crosscutting concerns such as transa 6 min read Spring Boot - Auto-configuration Spring Boot is heavily attracting developers toward it because of three main features as follows: Auto-configuration - such as checking for the dependencies, the presence of certain classes in the classpath, the existence of a bean, or the activation of some property.An opinionated approach to confi 5 min read Spring Boot - EhCaching EhCache is an open-source and Java-based cache. It is used to boost performance. Its current version is 3. EhCache provides the implementation of the JSR-107 cache manager. Features of EhCache are given below: It is fast, lightweight, Flexible, and Scalable.It allows us to perform Serializable and O 5 min read Difference Between Spring Boot Starter Web and Spring Boot Starter Tomcat Spring Boot is built on the top of the spring and contains all the features of spring. And is becoming a favorite of developers these days because of its rapid production-ready environment which enables the developers to directly focus on the logic instead of struggling with the configuration and se 3 min read Spring Boot - Starter Test Spring Boot is built on top of the spring and contains all the features of spring. It is becoming a favorite of developers these days because of its rapid production-ready environment, which enables the developers to directly focus on the logic instead of struggling with the configuration and setup. 5 min read Like