java 如何通过 Maven 添加 hadoop 依赖项?我已经安装了 hadoop 并存在于我的 IDE 项目库中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11707115/
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
How to add hadoop dependency via Maven? I have hadoop installed and present in my IDE project library
提问by daydreamer
- I have hadoop installed on my system(I am using Mac 10.7)
- I am using Intellij IDEA as IDE and my hadoop project has listed hadoop*.jar as dependency
- When I do
mvn install
, it fails with the following error
- 我的系统上安装了 hadoop(我使用的是 Mac 10.7)
- 我使用 Intellij IDEA 作为 IDE,我的 hadoop 项目已将 hadoop*.jar 列为依赖项
- 当我这样做时
mvn install
,它失败并出现以下错误
(master) $ mvn clean install [INFO] Scanning for projects... [ERROR] The build could not read 1 project -> [Help 1] [ERROR] [ERROR] The project groupId:hadoop:master-SNAPSHOT (/Users/me/code/p/java/hadoop-programs/hadoop-programs/pom.xml)
has 1 error [ERROR] 'dependencies.dependency.systemPath' for org.apache.hadoop:hadoop-core:jar must be omitted. This field may only be specified for a dependency with system scope. @ line 18, column 25 [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
(master) $ mvn clean install [INFO] Scanning for projects... [ERROR] The build could not read 1 project -> [Help 1] [ERROR] [ERROR] The project groupId:hadoop:master-SNAPSHOT (/Users/me/code/p/java/hadoop-programs/hadoop-programs/pom.xml)
有 1 个错误 [ERROR] 'dependencies.dependency.systemPath' for org.apache.hadoop:hadoop-core:jar 必须被省略。只能为具有系统范围的依赖项指定此字段。@ 第 18 行,第 25 列 [错误] [错误] 要查看错误的完整堆栈跟踪,请使用 -e 开关重新运行 Maven。[错误] 使用 -X 开关重新运行 Maven 以启用完整的调试日志记录。[ERROR] [ERROR] 有关错误和可能的解决方案的更多信息,请阅读以下文章: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
I make changed to my pom.xml
as
我改变了我的pom.xml
作为
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>groupId</groupId>
<artifactId>hadoop</artifactId>
<version>master-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>1.0.3</version>
<type>jar</type>
<systemPath>/usr/local/Cellar/hadoop/1.0.3/libexec/hadoop-core-1.0.3.jar</systemPath>
</dependency>
</dependencies>
</project>
But still same error, How do I resolve this in Maven?
但仍然是同样的错误,我如何在 Maven 中解决这个问题?
回答by Satya
use this :
用这个 :
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>0.20.2</version>
</dependency>
回答by fidlr
A lot of the stuff in hadoop-core have moved to hadoop-client in newer versions, use -
hadoop-core 中的很多东西在新版本中已经转移到了 hadoop-client,使用 -
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-hdfs</artifactId>
<version>2.4.1</version>
</dependency>