【问题标题】:@AspectJ aspects not being weaved in application that uses Spring@AspectJ 方面未在使用 Spring 的应用程序中编织
【发布时间】:2016-07-18 18:27:08
【问题描述】:

我已经添加了<context:load-time-weaver/>这一行 到我的 application-context.xml,

并创建了一个META-INF\aop.xml 文件,其中包含以下内容:

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

    <weaver options="-verbose">
        <!-- only weave classes in our application-specific packages -->
        <include within="com.xxx.aspectj.*"/>
    </weaver>

    <aspects>
        <aspect name="com.xxx.aspectj.StandardAspect"/>
    </aspects>

</aspectj>

方面包括一个包罗万象的内容,以简单地查看它是否有效:

@After("call (public * *(..))")
public void interceptEverything() {
    System.out.println("Hello");
}

但似乎什么也没发生,有什么想法吗?

【问题讨论】:

    标签: spring aspectj spring-aspects


    【解决方案1】:

    删除include within 标签解决了我的问题。

    我意识到我误解了include within 标签,我认为这意味着只在列出的包中编织方面,但它意味着只将方面编织到列出的包中的类中。

    【讨论】:

      猜你喜欢
      • 2022-06-14
      • 2014-10-02
      • 1970-01-01
      • 2013-03-18
      • 1970-01-01
      • 2016-02-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多