Maven + AspectJ - all steps to configure it

Posted by Alice on Stack Overflow See other posts from Stack Overflow or by Alice
Published on 2012-09-14T11:51:22Z Indexed on 2012/09/16 15:38 UTC
Read the original article Hit count: 220

Filed under:
|
|

I have a problem with applying aspects to my maven project. Probably I am missing something, so I've made a list of steps. Could you please check if it is correct?

Let say in projectA is an aspect class and in projectB classes, which should be changed by aspects.

  • Create maven project ProjectA with AspectJ class
  • add Aspectj plugin and dependency
  • Add ProjectA as a dependency to projectB pom.xml
  • Add to projectB pom.xml plugin

"

<plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>aspectj-maven-plugin</artifactId>
        <version>1.4</version>
            <executions>
                <execution>
                    <goals>
                        <goal>compile</goal>
                        <goal>test-compile</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <source>${maven.compiler.source}</source>
                <target>${maven.compiler.target}</target>
                <aspectLibraries>
                    <aspectLibrary>
                        <groupId>ProjectA</groupId>
                        <artifactId>ProjectA</artifactId>
                    </aspectLibrary>
                </aspectLibraries>
            </configuration>
    </plugin>
  • Add aspectj dependency

After all these steps my problem is, that during compilation I get:

[WARNING] advice defined in AspectE has not been applied [Xlint:adviceDidNotMatch]

And then when I run my program:

Exception in thread "FeatureExcutionThread" java.lang.NoClassDefFoundError: AspectE

© Stack Overflow or respective owner

Related posts about java

Related posts about maven