使用新切入点编织外部方面 [英] Weave external aspect with new pointcut

查看:27
本文介绍了使用新切入点编织外部方面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

总的来说,我对 AOP 还很陌生,但我遇到了以下问题.

I'm pretty new to AOP in general, but I have the following problem.

我有 2 个项目.一个包含执行一些性能测试的方面和另一个依赖于前一个方面的项目.

I have 2 projects. One containing an aspect that does some performance testing and another project which has a dependency to the previous one.

我想要实现的是将项目 1 的方面编织到项目 2 的另一个方面.因此,对项目 2 的方面进行一些性能测试.

What I'd like to achieve is weave the aspect from project 1, into another aspect of project 2. As such doing some performance testing on the aspect of project 2.

我发现使用 Spring-AOP 是不可能的,但是使用 AspectJ 的编织应该是可能的.但是,我不知道如何.

I found out it's not possible with Spring-AOP, but it should be possible with AspectJ's weaving. However, I did not figure out how.

我很确定我需要使用 aspectj-maven-plugin,使用 AspectJ 文档.但是好像什么都没捡到?关于如何为外部方面编写额外切入点的任何指示?

Im pretty sure I need to make use of the aspectj-maven-plugin, using configuration as listed in the AspectJ documentation. But nothing seems to be picked up? Any pointers on how to write an extra pointcut for an external aspect?

推荐答案

最好张贴您相关的 maven pom.xml 片段,没有那个,我只能猜测您的问题:您是否指定您在 pom.xml 中的 aspectj-maven-plugin 配置中将 project 1 依赖项作为 aspect 库?示例取自 aspectj-maven-plugin 文档 并修改:

It would have been a good idea to post your relevant maven pom.xml fragments, without that, I can only have a guess at your problem: did you specify your project 1 dependency as an aspect library in your aspectj-maven-plugin configuration in your pom.xml? Example taken from the aspectj-maven-plugin documentation and modified:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>aspectj-maven-plugin</artifactId>
    <version>1.8</version>
    <configuration>
        <aspectLibraries>
            <aspectLibrary>
                <groupId>group.id.of.project.1</groupId>
                <artifactId>artifact.id.of.project.1</artifactId>
            </aspectLibrary>
        </aspectLibraries>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>compile</goal>
            </goals>
        </execution>
    </executions>
</plugin>

您还需要依赖于您的类路径,但我想您已经拥有了.

You'll also need the dependency on your classpath too, but I guess you have that already.

这篇关于使用新切入点编织外部方面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆