AspectJ support in IntelliJ IDEA Ultimate is enabled by default and includes the following features:
Ability to create aspects in two forms: as .aj files and java files containing classes annotated with
Coding assistance (including code completion) when writing aspect code. For annotation-style aspects, coding assistance is provided in full; for code-style aspects, assistance is limited to inter-type declarations.
Integration with the AcpectJ compiler ajc, which you can run right from the IDE. This compiler is part of the AspectJ distribution which you can download from the AspectJ website.
Ability to configure ajc at the project level with an option of fine-tuning its use at the level of individual modules.
Enable the AspectJ plugins if necessary
Add a library with the AspectJ runtime to your project
Download and install AspectJ as described on the Downloads page. The AspectJ runtime aspectjrt.jar should be located in the installation directory under /lib.
Open the Project Structure dialog Ctrl+Shift+Alt+S and select Libraries.
Click and select Java.
Specify the location of aspectjrt.jar in the file system.
Select the modules to which this library should be added and click OK.
Add AspectJ dependencies
Open the Project Structure dialog Ctrl+Shift+Alt+S and select Facets.
Click and select AspectJ.
Select the modules for which you want to use this facet and click OK.
Select the new AspectJ facet for the relevant module and add dependencies as paths to corresponding aspects.
Create an aspect
In the Project tool window, select the directory where you want to create the aspect, press Alt+Insert, and select Aspect.
Specify the name and type of the aspect file, and click OK.
Aspect creates an .aj file with the specified name.
@Aspect creates a .java file containing a class annotated with
If necessary, you can refactor the source code of your aspects.
To compile your aspects using the AspectJ compiler
ajc, select it as the project compiler.
ajc is in aspectjtools.jar, which is located in the installation directory under /lib.