我如何使Maven在我的Eclipse参考库中包含一个jar? [英] How do I get Maven to include a jar in my Eclipse Referenced Libraries?

查看:123
本文介绍了我如何使Maven在我的Eclipse参考库中包含一个jar?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用现有的Eclipse项目并添加一个pom.xml,以便我可以使用Maven进行自动化构建。在项目中,在参考库中有一个不在Maven存储库中的jar文件。为了让Maven识别jar文件,我需要做些什么?

I am attempting to take an existing Eclipse project and add a pom.xml so that I can use Maven for automated builds. In the project I have a jar file in the Referenced Libraries that is not in the Maven repository. What do I need to do in order to get Maven to recognize the jar file?

我没有任何成功的感觉,我没有任何成功的元素。

I have sort of fumbled around with the element without any success.

Windows XP,Eclipse 3.6.1 ,Maven 3.0.2

Windows XP, Eclipse 3.6.1, Maven 3.0.2

推荐答案

在你的pom.xml中添加一个< dependencies> 标签,并添加所有Jars依赖项。它将在构建时下载。

In your pom.xml add a <dependencies> tag and add all the Jars dependencies in that. It will be downloaded at the time of build.

像这样

<project>
  ...
  <dependencies>
    <dependency>
      <groupId>group-a</groupId>
      <artifactId>artifact-a</artifactId>
      <version>2.1</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>group-a</groupId>
      <artifactId>artifact-b</artifactId>
      <version>1.0</version>
      <type>jar</type>
      <scope>runtime</scope>
    </dependency>
  </dependencies>
     ....
</project>

在这里查看更多 http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html

对于公开的Jars,您可以在这里搜索依赖关系。 http://mvnrepository.com/

For publicly available Jars you can search the dependencies here http://mvnrepository.com/

对于不公开可用的Jars,您可以在本地安装,

For the Jars that are not publically available you can install locally, by

 mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>

看到这里

我不知道如何从里面安装第三方jar蚀。必须有一些方法使用m2eclipse插件。

I am not sure how to install third party jars from inside the Eclipse. There must be some way using m2eclipse plugin.

这篇关于我如何使Maven在我的Eclipse参考库中包含一个jar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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