2011-07-27 67 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

相關問題