如何为mahout和hadoop添加maven依赖?
我正在做一个项目,它依赖于 mahout 和 hadoop 核心 jar 中的一些类。我之前使用 javac 和 classpath 选项来包含它们,但有人建议我应该使用 Maven 来构建我的项目。但是,我不确定如何将依赖项添加到位于我的 /usr/local 目录中的这些 jar 文件中。
I am doing a project that has dependencies on some classes from the mahout and hadoop core jars. I was using javac with the classpath option to include them before, but someone suggested to me that I should use maven to build my project instead. However, I am not sure how to add the dependencies to these jar files which are located in my /usr/local directory.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将其添加到您的 pom 中:
如果您有要用于上面的
hadoop
示例的 jar 副本,请执行以下命令:Add this to your pom:
If you have a copy of the jar to be used for say the
hadoop
example above, execute this command:查看maven文档,尤其是依赖管理部分。如果您想使用 Maven,您应该了解基础知识(其中之一是依赖管理)。
基本上,您可以在 pom.xml 的
部分定义项目的依赖项。查找 Maven Central(最常见的在线存储库)以获取所需的依赖项,或搜索可能包含它们的其他在线存储库。如果找不到它们,请添加您想要的依赖项(考虑一个合理的组 ID、工件 ID 和版本)并尝试编译。 Maven 会抱怨缺少依赖项,并提供一个基本命令将这些依赖项放入本地存储库。复制这些命令并填写 jar 文件的适当路径,maven 将在本地存储库中部署该依赖项。
请注意,您应该首先在在线存储库中查找依赖项,否则您必须在本地存储库中手动部署每个新版本。
Have a look at the maven documentation, especially the part on dependency management. If you want to use Maven you should get to know the basics (one of which is dependency management).
Basially you define your project's dependencies in the
<dependencies>
section of your pom. Look up maven central (the most common online repository) for the dependencies you want or search for other online repositories that might contain them.If you can't find them, add the dependencies you want anyways (think of a sensible group id, artifact id and version) and try to compile. Maven will complain about the dependencies missing and provide a basic command to put those dependencies into the local repository. Copy those commands and fill in the appropriate path to the jar file and maven will deploy that dependency in your local repository.
Note that you should first look for the dependencies in an online repository since otherwise you'd have to manually deploy each new version in your local repo.