【发布时间】:2015-08-01 13:28:09
【问题描述】:
我正在通过 Maven 使用 Apache Spark,我正在尝试通过包含第 3 方 jar 并尝试在其中使用一些方法来修改源代码。
使用编译 Spark 项目时出现以下错误
mvn -Dhadoop.version=2.2.0 -Dscala-2.11 -DskipTests clean package
not found: object edu
[ERROR] import edu.xxx.cs.aggr._
我修改了ResultTask.scala 以包含导入语句。因此,maven 无法找到我尝试使用的 jar 并将其与项目链接。
我在 pom.xml 文件中添加了一个依赖项,例如:
<dependency>
<groupId>edu.xxx.cs</groupId>
<artifactId>aggr</artifactId>
<version>0.99</version>
<scope>system</scope>
<systemPath>${basedir}/aggr.jar</systemPath>
</dependency>
我要链接的 jar 文件与 spark pom.xml 文件位于同一目录中。我将此依赖项添加到 pom.xml。我将它插入到 pom.xml 文件中的两个现有依赖项之间。我不确定出了什么问题,但我现在只想链接 jar,以便我可以使用其中的方法。我也不确定是否应该使用特定于 groupId、artifactId 和 version 的任何内容。 edu.xxx.cs.aggr 是包含其他源文件和包的根包。我将不胜感激任何帮助。
更新
我用过
mvn install:install-file -Dfile=<path-to-file> -DgroupId=edu.xxx.cs -DartifactId=aggr -Dversion=0.99 -Dpackaging=jar to install the jar to the .m2 repo. I checked the repo to see if it was installed, and it was.
我把 pom.xml 中的依赖改成
<dependency>
<groupId>edu.purdue.cs</groupId>
<artifactId>aggr</artifactId>
<version>0.99</version>
</dependency>
我仍然遇到同样的错误。
【问题讨论】:
-
尝试手动将其添加到您的本地 maven 存储库的位置
/edu/xxx/cs/aggr/0.99/aggr-0.99.jar -
这是错误的方法,不能保证它会一直有效。 Maven 提供其原生解决方案,而不是手动更改其工件库。
-
如果你在 zip 工具中打开那个 aggr.jar 文件,我想知道里面真的有一个目录“edu”吗?
-
我在 eclipse 上创建的一个简单的 java 项目中使用了这个 jar。导入语句 edu.xxx.cs.aggr 不会在该项目中产生任何错误。
标签: java maven apache-spark