I use Spring aop and Aspectj at compile time. The project structure is as follows
parent-module
|---aop
|---service
|---web-app
aop related stuff including annotation interface and aspects are in project aop, aop annotations are used in project service, and services are used in web-app
aspectj compile time weaving is applied to both service and web-app, pom is like
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.8</version>
<configuration>
<weaveDependencies>
<weaveDependency>
<groupId>com.group</groupId>
<artifactId>aop</artifactId>
</weaveDependency>
</weaveDependencies>
<aspectLibraries>
<aspectLibrary>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</aspectLibrary>
</aspectLibraries>
<complianceLevel>1.8</complianceLevel>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<showWeaveInfo>true</showWeaveInfo>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
This way, it works perfectly.
but since I think aspects are woven into service at compile time, why can't I remove aspectj compiler from web-app, then
java.lang.NoSuchMethodError: aspectOf() error
occurs when the aspects are invoked.
Why this is happening? What can I put in web-app's pom to make service's aspect work? Do I have to let aspectj weave both service and web-app at compile time?