Eclipse 中的 Maven/AJDT 项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6522540/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Maven/AJDT project in Eclipse
提问by Magen
I need to use aspectj in a maven project. I installed the maven plugin for eclipse (m2e), the maven aspectj plugin, and also AJDT for Eclipse. So now, when i open a new project i have "Maven Project" and "AspectJ Project". how can i make a new project that is Maven AspectJ project? I did not found any reference for that, so you are my only hope. thanks
我需要在 Maven 项目中使用 aspectj。我安装了 eclipse (m2e) 的 maven 插件、maven aspectj 插件以及 Eclipse 的 AJDT。所以现在,当我打开一个新项目时,我有“Maven 项目”和“AspectJ 项目”。我如何创建一个新项目,即 Maven AspectJ 项目?我没有找到任何参考资料,所以你是我唯一的希望。谢谢
回答by Hendy Irawan
- Go to Help > Install New Software...
- Use this software repository: http://dist.springsource.org/release/AJDT/configurator/
- Install the AJDT m2e Configurator
- 转到帮助 > 安装新软件...
- 使用这个软件仓库:http: //dist.springsource.org/release/AJDT/configurator/
- 安装 AJDT m2e 配置器
Source: http://blog.springsource.com/2011/10/18/upgrading-maven-integration-for-springsource-tool-suite-2-8-0/#comment-207264(Andrew Eisenberg)
资料来源:http: //blog.springsource.com/2011/10/18/upgrading-maven-integration-for-springsource-tool-suite-2-8-0/#comment-207264(Andrew Eisenberg)
回答by Torsten
You should add the maven-aspectj-plugin to your build plugins section in your pom.xml as in:
您应该将 maven-aspectj-plugin 添加到 pom.xml 中的 build plugins 部分,如下所示:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<!-- use this goal to weave all your main classes -->
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<complianceLevel>1.6</complianceLevel>
</configuration>
</plugin>
回答by Joel Hudon
Check AJDT project configurator for m2eclipse
检查 m2eclipse 的 AJDT 项目配置器
The m2eclipse-AJDT plugin detect that the pom.xml
contains the aspectj-maven-plugin
and add automatically the relevant AJDT
nature and configuration to the project when importing it in eclipse.
m2eclipse-AJDT 插件检测到pom.xml
包含aspectj-maven-plugin
并AJDT
在 eclipse 中导入时自动将相关的性质和配置添加到项目中。
I think some effort have bean made for the plugin to work with version 0.12 of m2eclipse , dont know if it's worked.
我认为 bean 为插件与 m2eclipse 的 0.12 版本一起工作做了一些努力,不知道它是否有效。
I already try the plugin with m2eclipse 0.10 and it worked well.
我已经在 m2eclipse 0.10 上试用了这个插件,而且效果很好。
See GitHub m2eclipse-ajdt project
See Move AJDT integration out of main m2e source tree
回答by Yiling
- Firstly we need to make sure AJDT (AspectJ development tools) is installed for eclipse. Check out the latest or appropriate version of AJDT for your Eclipse. (http://www.eclipse.org/ajdt/)
- Secondly install "AJDT m2e Configurator" using this repository http://dist.springsource.org/release/AJDT/configurator/(As Hendy described above).
- If you have previously installed m2eclipse, you need to uninstall it before performing step 2.
- 首先,我们需要确保为 Eclipse 安装了 AJDT(AspectJ 开发工具)。为您的 Eclipse 查看最新或合适的 AJDT 版本。( http://www.eclipse.org/ajdt/)
- 其次,使用此存储库http://dist.springsource.org/release/AJDT/configurator/(如 Hendy 所述)安装“AJDT m2e Configurator” 。
- 如果之前安装过m2eclipse,需要先卸载再执行步骤2。
回答by Christophe
If you have the aspectj-maven-plugin in your pom.xml you'll get one missing m2e connector :
如果您的 pom.xml 中有 aspectj-maven-plugin,您将丢失一个 m2e 连接器:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.11</version>
<configuration>
<includes>
<include>**/*aj</include>
<include>**/*java</include>
</includes>
<Xlint>ignore</Xlint>
<source>1.8</source>
<target>1.8</target>
<complianceLevel>1.8</complianceLevel>
<showWeaveInfo>true</showWeaveInfo>
<weaveDependencies>
<weaveDependency>
<groupId>org.perf4j</groupId>
<artifactId>perf4j</artifactId>
<classifier>log4jonly</classifier>
</weaveDependency>
</weaveDependencies>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
I had to install m2e AJDT maven plugin configurator in eclipse but it did not work at first because I had missing dependencies.
So to start install the AJDT tool available on this site : http://download.eclipse.org/tools/ajdt/48/dev/update/
Restart eclipse and then the install of m2e AJDT maven plugin configurator should work. After a new restart you should have eclipse available to build your aspectj classes.
我必须在 eclipse 中安装 m2e AJDT maven 插件配置器,但它起初不起作用,因为我缺少依赖项。因此,要开始安装此站点上可用的 AJDT 工具:http: //download.eclipse.org/tools/ajdt/48/dev/update/
重新启动 eclipse,然后安装 m2e AJDT maven 插件配置器应该可以工作。重新启动后,您应该可以使用 eclipse 来构建您的 aspectj 类。
回答by bhagyas
You will have to add the relevant project facets to your project configuration in eclipse after adding the AspectJ support in your maven pom.xml
.
在您的 maven 中添加 AspectJ 支持后,您必须在 eclipse 中将相关的项目方面添加到您的项目配置中pom.xml
。