简体   繁体   English

Eclipse如何将jar文件导入为Maven项目

[英]Eclipse how to import a jar file as a maven project

I have downloaded a source jar file of OrientDB from maven repo, orientdb-source.jar. 我已经从Maven仓库orientdb-source.jar下载了OrientDB的源jar文件。 The structure is: 结构为:

orientdb-source.jar/com/orienttechnologies/orient/core/...
                   /META-INF/...

I have installed m2e plugin. 我已经安装了m2e插件。 But I dont know to import this jar file as a maven project. 但我不知道将这个jar文件导入为Maven项目。 I dont want to import this jar file as an external jar. 我不想将此jar文件作为外部jar导入。 Can anyone help me? 谁能帮我?

It sounds like you want to use/access this artifact within a maven environment. 听起来您想在Maven环境中使用/访问此工件。

If all you want to do is use the jar in your class path you should add the jar as a dependency in your project's pom file. 如果您只想在类路径中使用jar,则应将jar作为依赖项添加到项目的pom文件中。 You may also need to add the repository reference to the pom if the jar is coming from a private repository. 如果罐子来自私有存储库,则可能还需要将存储库引用添加到pom。 Once your pom file is modified with the reference to the jar then you can select your project and click "Maven -> Update project dependencies". 一旦通过引用jar修改了pom文件,则可以选择项目,然后单击“ Maven->更新项目依赖项”。 Maven will download the jar and modify your class path. Maven将下载jar并修改您的类路径。

If you want to actually look at the source then look for a reference on the 3rd party's web site to the repository containing the source code. 如果要实际查看源代码,请在第三方的网站上查找包含源代码的存储库的引用。 Use the appropriate Eclipse plugin (git, svn, etc.) to point to and checkout the version of the source. 使用适当的Eclipse插件(git,svn等)指向并签出源代码的版本。

If you want to import the jar on your project, put this on your <dependecies> tag in pom.xml on root of your project: 如果要在项目上导入jar,请将其放在项目根目录pom.xml中的<dependecies>标记上:

<dependency>
    <groupId>com.orientechnologies</groupId>
    <artifactId>orientdb</artifactId>
    <version>1.3.0</version>
</dependency>

From Maven Repository Maven存储库

This will import the jar on your project lib folder. 这会将jar导入您的项目lib文件夹中。

Anyway, if you want to modify code from this lib, you need to create a new Project with content of this jar. 无论如何,如果要从此lib修改代码,则需要使用此jar的内容创建一个新Project。 Package as jar on maven and put as dependencie. 打包成罐子在Maven上,并作为依赖。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM