简体   繁体   English

配置到Maven项目

[英]Configuring to Maven Project

I was using eclipse for building my project. 我正在使用eclipse构建我的项目。 Now I am configuring the project to Maven project. 现在,我将项目配置为Maven项目。 All the libs were manually downloaded to lib folder. 所有库均已手动下载到lib文件夹。 If I do a Maven build, Maven is unable to map those libs. 如果我执行Maven构建,则Maven无法映射这些库。 There are lots of libs, I don't want to manually place them in pom.xml. 有很多库,我不想手动将它们放在pom.xml中。 What is the best way out? 最好的出路是什么?

I have read few answers, first declare local repo and then add the respective dependencies. 我读了几个答案,首先声明本地仓库,然后添加相应的依赖项。 But again I don't want to add all the dependencies manually. 但是我又不想手动添加所有依赖项。

Maven: best way of linking custom external JAR to my project? Maven:将自定义外部JAR链接到我的项目的最佳方法是什么?

1.) Install locally 1.)本地安装

There are two scopes which are interesting for you. 有两个范围对您来说很有趣。 If you declare a scope "runtime" (which is the default scope) and have a local repository configured, maven will try to download the file from your local repository. 如果您声明范围“运行时”(这是默认范围)并配置了本地存储库,则maven会尝试从本地存储库下载文件。

2.) System dependency 2.)系统依赖性

If you just don't want maven to manage dependencies, you can (although shan't) use the system scope like this: 如果您只是不想让Maven管理依赖项,则可以(尽管不行)使用如下系统范围:

<dependency>
    ...
    <scope>system</scope>
    <systemPath>/path/to/dependency.jar</systemPath>
</dependency>

The downsides are: 缺点是:

  • the system scope is deprecated and might not work in future versions of maven. 系统范围已弃用,在将来的Maven版本中可能无法使用。
  • you need to check in a jar file, which is not a good idea . 您需要检入一个jar文件, 这不是一个好主意
  • it may not be portable (eg architecture dependent libraries). 它可能不是可移植的(例如,依赖于体系结构的库)。

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

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