2010-09-22 75 views
2

我想将我的加载时编织aspectj转换为编译时编织。编译时编织配置

所以我从我的spring配置中删除了<context:load-time-weaver/>,并在我的pom.xml中添加了一个aspectj编译器。但我不知道如何转换信息META-INF/aop.xml

我有这样的事情在那里:

<!DOCTYPE aspectj PUBLIC 
     "-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd"> 
<aspectj> 
    <weaver> 
     <!-- only weave classes in this package --> 
    </weaver> 
    <aspects> 
     <!-- use only this aspect for weaving --> 
     <concrete-aspect name="MyAspect_" extends="hu.myAspect"> 
     <pointcut name="pointcut" expression="execution(public * javax.persistence.EntityManager.*(..)) || execution(public * hu..*.create(..))"/> 
     </concrete-aspect> 
    </aspects> 
</aspectj> 

回答

4

没有完全等效于编译时织入aop.xml文件,但你可以配置AspectJ maven plugininclude and exclude certain aspects这样

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>aspectj-maven-plugin</artifactId> 
    <version>1.3</version> 
    <configuration> 
     <includes> 
      <include>**/TransationAspect.java</include> 
      <include>**/SecurityAspect.aj</include> 
     </includes> 
     <excludes> 
      <exclude>**/logging/*.aj</exclude> 
     </excludes> 
    </configuration> 
    <executions> 
     <execution> 
      <goals> 
       <goal>compile</goal> 
      </goals> 
     </execution> 
    </executions> 
</plugin> 
+0

感谢您的回答,但是我可以在那里配置切入点吗? – pihentagy 2010-09-23 07:23:44

+0

我不认为你可以。我认为你只能包含/排除整个方面,而不是单个切入点。也许ajdt生成def文件是一个选项(但我不知道):http://mojo.codehaus.org/aspectj-maven-plugin/compile-mojo.html#ajdtBuildDefFile – 2010-09-23 07:29:24

+0

我相信你必须指定basedir - 如果你用-X参数运行它,它就是它告诉你的。在我的情况下,我不得不放在那里 $ {basedir}/src/main/java kboom 2014-02-08 17:08:33