Skip to content

Compile-time weaving support for aspects #1149

@jefftap

Description

@jefftap

Hi, I am attempting to make use of TimedAspect via AspectJ compile-time weaving using the aspectj-maven-plugin. When the aspect code is executed, it throws one of the two errors, depending on what is being executed:

java.lang.NoSuchMethodError: io.micrometer.core.aop.TimedAspect.aspectOf()Lio/micrometer/core/aop/TimedAspect
java.lang.NoSuchMethodException: io.micrometer.core.aop.TimedAspect.aspectOf()

This usually indicates that the AspectJ weaver has not properly processed the aspect code. I am not sure if this is a problem with my own code/configuration, or if it's an issue in Micrometer's jar. The aspect works perfectly fine using Spring AOP, but I would prefer to use AspectJ weaving with @Timed to allow it access to private/protected methods and the other various benefits one gets from AspectJ integration.

Relevant information:

  • micrometer-core version: 1.1.1
  • Spring Boot version: 2.1.1.RELEASE
  • AspectJ verison: 1.9.2
  • Java version: 1.8
  • aspectj-maven-plugin version: 1.11

aspectj-maven-plugin configuration:

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>aspectj-maven-plugin</artifactId>
                <version>1.11</version>
                <configuration>
                    <complianceLevel>1.8</complianceLevel>
                    <source>1.8</source>
                    <target>1.8</target>
                    <showWeaveInfo>true</showWeaveInfo>
                    <Xlint>ignore</Xlint>
                    <aspectLibraries>
                        <aspectLibrary>
                            <groupId>org.springframework</groupId>
                            <artifactId>spring-aspects</artifactId>
                        </aspectLibrary>
                        <aspectLibrary>
                            <groupId>io.micrometer</groupId>
                            <artifactId>micrometer-core</artifactId>
                        </aspectLibrary>
                    </aspectLibraries>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>test-compile</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjtools</artifactId>
                        <version>${aspectj.version}</version>
                    </dependency>
                </dependencies>
            </plugin>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions