0

I'm trying to use the AspectJ aspects in conjunction with Spring boot. But seems Spring can't see aspect classes compiled with Ajc compiler, and I get the error that there is no package containing my aspects found.

I'm using the following aspectj-maven-plugin configuration:

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>aspectj-maven-plugin</artifactId>
            <version>1.10</version>
            <dependencies>
                <dependency>
                    <groupId>org.aspectj</groupId>
                    <artifactId>aspectjtools</artifactId>
                    <version>1.8.9</version>
                </dependency>
                <dependency>
                    <groupId>org.aspectj</groupId>
                    <artifactId>aspectjrt</artifactId>
                    <version>1.8.9</version>
                </dependency>
            </dependencies>
            <configuration>
                <complianceLevel>1.8</complianceLevel>
                <source>1.8</source>
                <target>1.8</target>
                <showWeaveInfo>true</showWeaveInfo>
                <verbose>true</verbose>
                <Xlint>ignore</Xlint>
                <encoding>UTF-8 </encoding>
                <weaveDirectories>
                    <weaveDirectory>${project.build.directory}/classes</weaveDirectory>
                </weaveDirectories>
                <forceAjcCompile>true</forceAjcCompile>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>compile</goal>
                        <goal>test-compile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

Also the following dependency has been added:

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-aop</artifactId>
    </dependency>

Configured aop config in spring:

@Configuration
public class AspectJConfig {

    @Bean
    public MyAspect myAspect() {
        return Aspects.aspectOf(MyAspect.class);
    }
}

I can't figure out what the reason that my Aspect classes finally can't be found. Any help is appreciated.

androberz
  • 744
  • 10
  • 25

0 Answers0