AspectJ Plugin Aspect Config with Maven using exte

2019-07-23 05:50发布

I am using Perf4j to do performance logging.

It specifies that you use aop.xml to define which Aspect you want to be called at compile time depending on which logging system you are using. I cannot get it to pick up the aop.xml file which is in src/main/webapp/meta-inf/aop.xml

I cannot figure out how to get my Maven plugin to only weave the log4j aspect.

                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>aspectj-maven-plugin</artifactId>
                    <version>1.3</version>
                    <configuration>
                        <showWeaveInfo>true</showWeaveInfo>
                        <outxml>true</outxml>
                        <source>1.6</source>
                         <target>1.6</target>
                        <weaveDependencies>
                            <dependency>
                                <groupId>org.perf4j</groupId>
                                <artifactId>perf4j</artifactId>
                            </dependency>
                        </weaveDependencies>
                        <aspects>
                            <includes>
                                  <include>org.perf4j.log4j.aop.TimingAspect</include>
                            </includes>
                        </aspects>
                    </configuration>
                    <executions>
                        <execution>
                            <goals>
                                <goal>compile</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

When I package I get the following.

[INFO] --- aspectj-maven-plugin:1.3:compile (default) @ trace-web ---
[INFO] Join point 'method-execution(org.springframework.web.servlet.ModelAndView com.idna.trace.web.controllers.TraceJSONController.getResults(javax.servlet.http.HttpServletResponse, javax.servlet.http.HttpServletRequest))' in Type 'com.idna.trace.web.controllers.TraceJSONController' (TraceJSONController.java:121) advised by around advice from 'org.perf4j.commonslog.aop.TimingAspect' (perf4j-0.9.13.jar!AbstractTimingAspect.class(from AbstractTimingAspect.java))
[INFO] Join point 'method-execution(org.springframework.web.servlet.ModelAndView com.idna.trace.web.controllers.TraceJSONController.getResults(javax.servlet.http.HttpServletResponse, javax.servlet.http.HttpServletRequest))' in Type 'com.idna.trace.web.controllers.TraceJSONController' (TraceJSONController.java:121) advised by around advice from 'org.perf4j.log4j.aop.TimingAspect' (perf4j-0.9.13.jar!AbstractTimingAspect.class(from AbstractTimingAspect.java))
[INFO] Join point 'method-execution(org.springframework.web.servlet.ModelAndView com.idna.trace.web.controllers.TraceJSONController.getResults(javax.servlet.http.HttpServletResponse, javax.servlet.http.HttpServletRequest))' in Type 'com.idna.trace.web.controllers.TraceJSONController' (TraceJSONController.java:121) advised by around advice from 'org.perf4j.javalog.aop.TimingAspect' (perf4j-0.9.13.jar!AbstractTimingAspect.class(from AbstractTimingAspect.java))
[INFO] Join point 'method-execution(org.springframework.web.servlet.ModelAndView com.idna.trace.web.controllers.TraceJSONController.getResults(javax.servlet.http.HttpServletResponse, javax.servlet.http.HttpServletRequest))' in Type 'com.idna.trace.web.controllers.TraceJSONController' (TraceJSONController.java:121) advised by around advice from 'org.perf4j.slf4j.aop.TimingAspect' (perf4j-0.9.13.jar!AbstractTimingAspect.class(from AbstractTimingAspect.java))
[INFO] Join point 'method-execution(org.springframework.web.servlet.ModelAndView com.idna.trace.web.controllers.TraceHTMLController.getDetailsModelAndView(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.springframework.ui.Model))' in Type 'com.idna.trace.web.controllers.TraceHTMLController' (TraceHTMLController.java:106) advised by around advice from 'org.perf4j.commonslog.aop.TimingAspect' (perf4j-0.9.13.jar!AbstractTimingAspect.class(from AbstractTimingAspect.java))
[INFO] Join point 'method-execution(org.springframework.web.servlet.ModelAndView com.idna.trace.web.controllers.TraceHTMLController.getDetailsModelAndView(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.springframework.ui.Model))' in Type 'com.idna.trace.web.controllers.TraceHTMLController' (TraceHTMLController.java:106) advised by around advice from 'org.perf4j.log4j.aop.TimingAspect' (perf4j-0.9.13.jar!AbstractTimingAspect.class(from AbstractTimingAspect.java))
[INFO] Join point 'method-execution(org.springframework.web.servlet.ModelAndView com.idna.trace.web.controllers.TraceHTMLController.getDetailsModelAndView(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.springframework.ui.Model))' in Type 'com.idna.trace.web.controllers.TraceHTMLController' (TraceHTMLController.java:106) advised by around advice from 'org.perf4j.javalog.aop.TimingAspect' (perf4j-0.9.13.jar!AbstractTimingAspect.class(from AbstractTimingAspect.java))
[INFO] Join point 'method-execution(org.springframework.web.servlet.ModelAndView com.idna.trace.web.controllers.TraceHTMLController.getDetailsModelAndView(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.springframework.ui.Model))' in Type 'com.idna.trace.web.controllers.TraceHTMLController' (TraceHTMLController.java:106) advised by around advice from 'org.perf4j.slf4j.aop.TimingAspect' (perf4j-0.9.13.jar!AbstractTimingAspect.class(from AbstractTimingAspect.java))
[INFO] Join point 'method-execution(org.springframework.web.servlet.ModelAndView com.idna.trace.web.controllers.TraceHTMLController.getDetailsAddressModelAndView(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.springframework.ui.Model))' in Type 'com.idna.trace.web.controllers.TraceHTMLController' (TraceHTMLController.java:282) advised by around advice from 'org.perf4j.commonslog.aop.TimingAspect' (perf4j-0.9.13.jar!AbstractTimingAspect.class(from AbstractTimingAspect.java))
[INFO] Join point 'method-execution(org.springframework.web.servlet.ModelAndView com.idna.trace.web.controllers.TraceHTMLController.getDetailsAddressModelAndView(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.springframework.ui.Model))' in Type 'com.idna.trace.web.controllers.TraceHTMLController' (TraceHTMLController.java:282) advised by around advice from 'org.perf4j.log4j.aop.TimingAspect' (perf4j-0.9.13.jar!AbstractTimingAspect.class(from AbstractTimingAspect.java))
[INFO] Join point 'method-execution(org.springframework.web.servlet.ModelAndView com.idna.trace.web.controllers.TraceHTMLController.getDetailsAddressModelAndView(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.springframework.ui.Model))' in Type 'com.idna.trace.web.controllers.TraceHTMLController' (TraceHTMLController.java:282) advised by around advice from 'org.perf4j.javalog.aop.TimingAspect' (perf4j-0.9.13.jar!AbstractTimingAspect.class(from AbstractTimingAspect.java))
[INFO] Join point 'method-execution(org.springframework.web.servlet.ModelAndView com.idna.trace.web.controllers.TraceHTMLController.getDetailsAddressModelAndView(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.springframework.ui.Model))' in Type 'com.idna.trace.web.controllers.TraceHTMLController' (TraceHTMLController.java:282) advised by around advice from 'org.perf4j.slf4j.aop.TimingAspect' (perf4j-0.9.13.jar!AbstractTimingAspect.class(from AbstractTimingAspect.java))
[INFO] Join point 'method-execution(org.springframework.web.servlet.ModelAndView com.idna.trace.web.controllers.TraceHTMLController.getDetailsBmdModelAndView(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.springframework.ui.Model))' in Type 'com.idna.trace.web.controllers.TraceHTMLController' (TraceHTMLController.java:419) advised by around advice from 'org.perf4j.commonslog.aop.TimingAspect' (perf4j-0.9.13.jar!AbstractTimingAspect.class(from AbstractTimingAspect.java))
[INFO] Join point 'method-execution(org.springframework.web.servlet.ModelAndView com.idna.trace.web.controllers.TraceHTMLController.getDetailsBmdModelAndView(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.springframework.ui.Model))' in Type 'com.idna.trace.web.controllers.TraceHTMLController' (TraceHTMLController.java:419) advised by around advice from 'org.perf4j.log4j.aop.TimingAspect' (perf4j-0.9.13.jar!AbstractTimingAspect.class(from AbstractTimingAspect.java))
[INFO] Join point 'method-execution(org.springframework.web.servlet.ModelAndView com.idna.trace.web.controllers.TraceHTMLController.getDetailsBmdModelAndView(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.springframework.ui.Model))' in Type 'com.idna.trace.web.controllers.TraceHTMLController' (TraceHTMLController.java:419) advised by around advice from 'org.perf4j.javalog.aop.TimingAspect' (perf4j-0.9.13.jar!AbstractTimingAspect.class(from AbstractTimingAspect.java))
[INFO] Join point 'method-execution(org.springframework.web.servlet.ModelAndView com.idna.trace.web.controllers.TraceHTMLController.getDetailsBmdModelAndView(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.springframework.ui.Model))' in Type 'com.idna.trace.web.controllers.TraceHTMLController' (TraceHTMLController.java:419) advised by around advice from 'org.perf4j.slf4j.aop.TimingAspect' (perf4j-0.9.13.jar!AbstractTimingAspect.class(from AbstractTimingAspect.java))
[INFO] 

The answer is that Perf4J must specify log4jonly and it cannot be done in the maven plugin configuration as far as I could see.

    <dependency>
        <groupId>org.perf4j</groupId>
        <artifactId>perf4j</artifactId>
        <version>0.9.13</version>
        <classifier>log4jonly</classifier>
    </dependency>

1条回答
萌系小妹纸
2楼-- · 2019-07-23 06:21

The answer is that Perf4J must specify log4jonly and it cannot be done in the maven plugin configuration as far as I could see.

<dependency>
        <groupId>org.perf4j</groupId>
        <artifactId>perf4j</artifactId>
        <version>0.9.13</version>
        <classifier>log4jonly</classifier>
    </dependency>
查看更多
登录 后发表回答