You can turn off compile-time weaving, which I believe your IDE runs, and use load-time markup in your individual AspectJ tests.
To enable weaving at boot time, you need to provide javaagent as a JVM parameter.
Example:
-javaagent:lib/spring-dependencies/spring-agent.jar
Other changes when switching from compile time to triangulation at boot time
You must also provide the aop.xml file in the META-INF folder on claspath. For my trace example, it looks like this:
<!DOCTYPE aspectj PUBLIC "-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd"> <aspectj> <weaver> <include within="aspects.trace.demo.*" /> </weaver> <aspects> <aspect name="aspects.trace.TraceAspect" /> </aspects> </aspectj>
In this configuration, you will see that the TraceAspect class will be woven with all classes in the demo package.
Spring boot-time spinning configuration
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <bean id="traceAspect" class="aspects.trace.TraceAspect" factory-method="aspectOf"/> <context:load-time-weaver /> </beans>
The configuration file is almost the same as the compile-time configuration file, except that it also contains a load-time weaving element.
Hope this helps!
Espen source share