2011-07-27 66 views
9

似乎必须在使用某些特定于Eclipse的配置或“Maven项目”的“AspectJ项目”之间进行选择,然后尝试获取AspectJ的XML配置权限。如何使用AspectJ支持在Eclipse中创建Maven项目?

是否有一些我缺少的Eclipse功能,或者是否存在我可以用作开始的“预制”/教程项目? PS:我使用Eclipse 3.7(Indigo)。

+0

如果您使用的是Indigo,则使用AspectJ需要新的秘密解码器环和握手。基本上,m2e家伙决定打破所有在Indigo中生成代码的东西,以使其更好。我对此有态度问题 - 你能告诉吗?在这里搜索AspectJ/Indigo/m2e-or-m2eclipse获取更多信息 - 我不想特别链接到任何东西,因为它在不断发展。 –

回答

9

这是我用来学习AspectJ的pom文件。

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 

    <modelVersion>4.0.0</modelVersion> 
    <groupId>com.kowsercse</groupId> 
    <artifactId>hello-aop</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 

    <properties> 
     <java-version>1.6</java-version> 
     <org.aspectj-version>1.6.9</org.aspectj-version> 
    </properties> 

    <dependencies> 
     <!-- AspectJ --> 
     <dependency> 
      <groupId>org.aspectj</groupId> 
      <artifactId>aspectjrt</artifactId> 
      <version>${org.aspectj-version}</version> 
     </dependency> 
     <!-- Test --> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>4.7</version> 
      <scope>test</scope> 
     </dependency> 
    </dependencies> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <configuration> 
        <source>${java-version}</source> 
        <target>${java-version}</target> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-dependency-plugin</artifactId> 
       <executions> 
        <execution> 
         <id>install</id> 
         <phase>install</phase> 
         <goals> 
          <goal>sources</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>aspectj-maven-plugin</artifactId> 
       <!-- 
        Have to use version 1.2 since version 1.3 does not appear to work 
        with ITDs 
       --> 
       <version>1.2</version> 
       <dependencies> 
        <!-- 
         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>${org.aspectj-version}</version> 
        </dependency> 
        <dependency> 
         <groupId>org.aspectj</groupId> 
         <artifactId>aspectjtools</artifactId> 
         <version>${org.aspectj-version}</version> 
        </dependency> 
       </dependencies> 
       <executions> 
        <execution> 
         <goals> 
          <goal>compile</goal> 
          <goal>test-compile</goal> 
         </goals> 
        </execution> 
       </executions> 
       <configuration> 
        <outxml>true</outxml> 
        <source>${java-version}</source> 
        <target>${java-version}</target> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 
</project> 
+0

这将使用Eclipse 3.7吗? – soc

+0

我使用eclipse helios和eclipse AJDT插件。我没有看到任何具体问题,这会引发任何问题与日食3.7一起工作。我将在一段时间后上传该项目。 – Kowser

+0

我认为你只是使用eclipse来构建你的AspectJ maven项目。如果是这样,它不会有帮助,你必须需要插件。 https://bitbucket.org/kowsercse/hello-aop – Kowser

相关问题