如何使Maven设置(并保持最新)我的Eclipse项目的构建路径? [英] How can I make Maven set up (and keep up to date) the build path for my Eclipse project?

查看:75
本文介绍了如何使Maven设置(并保持最新)我的Eclipse项目的构建路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在pom.xml文件中定义了用于编译,测试和运行程序的依赖项.但是Eclipse仍然有一个单独配置的构建路径,因此无论何时更改其中一个,都必须手动更新另一个.我猜这是可以避免的吗?怎么样?

I define the dependencies for compiling, testing and running my programs in the pom.xml files. But Eclipse still has a separately configured build path, so whenever I change either, I have to manually update the other. I guess this is avoidable? How?

推荐答案

使用 m2eclipse IAM (以前是 Q4E ).两者都提供(以及其他功能)一种方法,每当执行一个干净的构建时就重新计算Maven依赖关系,并将依赖关系作为类路径容器呈现给Eclipse.有关详细信息,请参见比较Eclipse Maven集成.

Use either m2eclipse or IAM (formerly Q4E). Both provide (amongst other features) a means to recalculate the Maven dependencies whenever a clean build is performed and presents the dependencies to Eclipse as a classpath container. See this comparison of Eclipse Maven integrations for details.

此刻,我个人将使用m2eclipse,尤其是如果您使用AspectJ进行开发.有一个用于m2eclipse的可选插件,该插件将AspectLi-Libraries从Aspectj-Maven-plugin公开给Eclipse,从而避免了整个类的集成问题.

I would personally go for m2eclipse at the moment, particularly if you do development with AspectJ. There is an optional plugin for m2eclipse that exposes the aspectLibraries from the aspectj-maven-plugin to Eclipse that avoids a whole class of integration issues.

要在现有项目上启用m2eclipse,请在 Package Explorer 视图中右键单击它,然后选择 Maven -> 启用依赖管理 >,这会将Maven构建器添加到.project文件,并将classpath容器添加到.classpath文件.

To enable m2eclipse on an existing project, right-click on it in the Package Explorer view, then select Maven->Enable Dependency Management, this will add the Maven builder to the .project file, and the classpath container to the .classpath file.

还有一个eclipse:eclipse目标,但我发现这比它要麻烦的多,因为它创建了非常基本的.project和.classpath文件(尽管它对于初始项目设置很有用),所以如果您遇到任何麻烦根据您的配置,您每次都必须重新应用它们.公平地说,这是一个较旧的版本,现在处理边缘情况可能会更好.

There is also an eclipse:eclipse goal, but I found this more trouble than it is worth as it creates very basic .project and .classpath files (though it is useful for initial project setup), so if you have any complications to your configuration you'll have to reapply them each time. To be fair this was an older version and it might be better at handling the edge cases now.

这篇关于如何使Maven设置(并保持最新)我的Eclipse项目的构建路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆