添加系统依赖到Maven [英] Adding a system dependency to Maven

查看:233
本文介绍了添加系统依赖到Maven的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Maven通过与Apache星火工作,我试图通过包括第三方罐子,试图利用在它的一些方法来修改源代码。

I am working with Apache Spark through Maven, and I am trying to modify the source by including a 3rd party jar and trying to utilize some methods within it.

使用编译星火项目时,我得到了以下错误

I get the following error when compiling the Spark project using

mvn -Dhadoop.version=2.2.0 -Dscala-2.11 -DskipTests clean package

not found: object edu
[ERROR] import edu.xxx.cs.aggr._

我修改 ResultTask.scala 包含一个import语句。因此,Maven是找不到我试图使用和项目链接它的罐子。

I modified ResultTask.scala to contain an import statement. So, maven is unable to find the jar I am trying to use and link it with the project.

我添加了一个依赖于pom.xml文件像这样:

I have added a dependency to the pom.xml file such as this:

<dependency>
    <groupId>edu.xxx.cs</groupId>
    <artifactId>aggr</artifactId>
    <version>0.99</version>
    <scope>system</scope>
    <systemPath>${basedir}/aggr.jar</systemPath>
</dependency>

我试图链接,jar文件位于同一目录的火花pom.xml文件。我说这种依赖到pom.xml中。我插入它在pom.xml文件内的2现有的依赖之间。我不知道什么是错的,但我只是想罐子得到现在挂了,这样我就可以在它使用的方法。我也不能确定我是否应该使用专用的的groupId,artifactId和版本的任何东西。 edu.xxx.cs.aggr是根包,其中包含其他源文件和包。我想AP preciate任何帮助。

The jar file I am trying to link is located in the same directory as the spark pom.xml file. I added this dependency to pom.xml. I inserted it in between 2 existing dependencies within the pom.xml file. I'm not sure whats wrong, but I would just like the jar to get linked for now, so that I can use the methods within it. I'm also not sure if I should be using anything specific for the groupId, artifactId, and version. edu.xxx.cs.aggr is the root package which contains other source files and packages. I would appreciate any help.

更新

我用

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中以

I changed the dependency in pom.xml to

<dependency>
        <groupId>edu.purdue.cs</groupId>
        <artifactId>aggr</artifactId>
        <version>0.99</version>
</dependency>

我仍然得到同样的错误。

I still get the same error.

推荐答案

这是我怎么加系统的依赖我的Maven的pom.xml。在项目的根路径,我已经创建lib目录,在那里我已经把我的jar文件。

this is how I add system dependency to my maven pom.xml. with in the project root path, I have created lib directory and there I have placed my jar file.

<dependency>
    <groupId>com.sshx</groupId>
    <artifactId>sshx</artifactId>
    <version>1.0</version>
    <scope>system</scope>
    <systemPath>${basedir}/lib/sshxcute-1.0.jar</systemPath>
</dependency>

如果你仍然面临着同样的问题,尝试通过从jar文件位置发出以下命令手动添加的依赖

if still you face the same issue try adding the dependency manually by issuing the following command from the jar file location

mvn install:install-file -Dfile=sshxcute-1.0.jar -DgroupId=com.sshx -DartifactId=sshx -Dversion=1.0 -Dpackaging=jar

此命令将罐子添加到您的存储库的.m2作为一个依赖,你需要改变的pom.xml依赖如下:

this command will add the jar to your .m2 repository as a dependency and you need to change the pom.xml dependency as follows:

<dependency>
    <groupId>com.sshx</groupId>
    <artifactId>sshx</artifactId>
    <version>1.0</version>
</dependency>

一旦你完成,问题的 MVN全新安装从命令提示符下命令和构建应用程序

once you are done, issue mvn clean install command from command prompt and build your application

这篇关于添加系统依赖到Maven的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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