How to enable aspectj compile time weaving with Java 7 and maven

后端 未结 1 1840
感动是毒
感动是毒 2020-12-08 01:15

I have a project which currently works with java 6 and compile time weaving. We use the following pom to enable spring aspects and our own ones:



        
相关标签:
1条回答
  • 2020-12-08 01:44

    After moving to version 1.7.0 of the aspectjtools it works fine. In addition you need to pass the compiler the version parameter as -1.7 (using the target parameter caused problems). If someone needs more details leave a comment and I'll add more configuration specific information.
    You can take a working example from here: Spring, AspectJ and Maven example
    Here is the working plugin definition from the pom (compiler-version="1.7", aspectj.version="1.7.0")

    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>aspectj-maven-plugin</artifactId>
        <version>1.4</version>
        <configuration>
            <showWeaveInfo>true</showWeaveInfo>
            <source>${compiler.version}</source>
            <target>${compiler.version}</target>
            <Xlint>ignore</Xlint>
            <complianceLevel>${compiler.version}</complianceLevel>
            <encoding>UTF-8</encoding>
            <verbose>false</verbose>
            <aspectLibraries>
                <aspectLibrary>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-aspects</artifactId>
                </aspectLibrary>
            </aspectLibraries>
        </configuration>
        <executions>
            <execution>
                <goals>
                    <goal>compile</goal>
                    <goal>test-compile</goal>
                </goals>
            </execution>
        </executions>
        <dependencies>
            <dependency>
                <groupId>org.aspectj</groupId>
                <artifactId>aspectjrt</artifactId>
                <version>${aspectj.version}</version>
            </dependency>
            <dependency>
                <groupId>org.aspectj</groupId>
                <artifactId>aspectjtools</artifactId>
                <version>${aspectj.version}</version>
            </dependency>
        </dependencies>
    </plugin>
    
    0 讨论(0)
提交回复
热议问题