如何使用aspectj maven插件指定aop.xml的路径

时间:2013-07-05 21:24:20

标签: aspectj spring-aop perf4j aspectj-maven-plugin

您好我的问题与AspectJ Plugin Aspect Config with Maven using external Jar for Aspect

几乎相同

这是我的pom.xml

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <!-- <configuration> <webXml>target/web.xml</webXml> </configuration> -->
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>aspectj-maven-plugin</artifactId>
            <dependencies>
                <!-- NB: You must use Maven 2.0.9 or above or these are ignored (see 
                    MNG-2972) -->
                <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>
            <executions>
                <execution>
                    <goals>
                        <goal>compile</goal>
                        <goal>test-compile</goal>
                    </goals>
                    <phase>process-sources</phase>
                </execution>
            </executions>
            <configuration>
                <outxml>true</outxml>
                <aspectLibraries>
                    <aspectLibrary>
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-aspects</artifactId>
                    </aspectLibrary>
                </aspectLibraries>
                <weaveDependencies>
                    <weaveDependency>
                        <groupId>${project.groupId}</groupId>
                        <artifactId>core</artifactId>
                    </weaveDependency>
            <weaveDependency>
              <groupId>${project.groupId}</groupId>
              <artifactId>core-client</artifactId>
            </weaveDependency>

        </weaveDependencies>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
    </build>

我在META-INF目录中有我的aop.xml,如下所示:

<!DOCTYPE aspectj PUBLIC "-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd">

<aspectj>
  <!--
    We only want to weave in the log4j TimingAspect into the @Profiled classes.
    Note that Perf4J provides TimingAspects for the most popular Java logging
    frameworks and facades: log4j, java.util.logging, Apache Commons Logging
    and SLF4J. The TimingAspect you specify here will depend on which logging
    framework you wish to use in your code.
  -->
  <aspects>
    <aspect name="org.perf4j.log4j.aop.TimingAspect"/>
    <!-- if SLF4J/logback use org.perf4j.slf4j.aop.TimingAspect instead -->
  </aspects>

  <weaver options="-verbose -showWeaveInfo">
    <!--
      Here is where we specify the classes to be woven. You can specify package
      names like com.company.project.*
    -->
    <include within="com.xyz.store.security.*"/>
  </weaver>
</aspectj>

我最终想要做的是: http://perf4j.codehaus.org/devguide.html#Using_the_AspectJ_Compiler_to_Integrate_Timing_Aspects_at_Compile_Time

0 个答案:

没有答案