Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
321 views
in Technique[技术] by (71.8m points)

java - 如何将本地jar文件添加到Maven项目?(How to add local jar files to a Maven project?)

如何在项目的库源代码中直接添加本地jar文件(尚未成为Maven存储库的一部分)?

  ask by Praneel PIDIKITI translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can add local dependencies directly (as mentioned in build maven project with propriatery libraries included ) like this:

(您可以像这样直接添加本地依赖项(如在包含专有库的build maven项目中提到的那样):)

<dependency>
    <groupId>com.sample</groupId>
    <artifactId>sample</artifactId>
    <version>1.0</version>
    <scope>system</scope>
    <systemPath>${project.basedir}/src/main/resources/Name_Your_JAR.jar</systemPath>
</dependency>

Update

(更新资料)

In new releases this feature is marked as deprecated but still working and not removed yet ( You just see warning in the log during maven start).

(在新版本中,此功能被标记为已弃用,但仍在工作并且尚未删除(您仅在maven启动期间在日志中看到警告)。)

An issue is raised at maven group about this https://issues.apache.org/jira/browse/MNG-6523 ( You can participate and describe why this feature is helpful in some cases).

(在Maven小组中,有关此https://issues.apache.org/jira/browse/MNG-6523的问题 (您可以参与并描述此功能在某些情况下有帮助的原因)。)

I hope this feature remains there!

(我希望此功能仍然存在!)

If you are asking me, as long as the feature is not removed, I use this to make dependency to only one naughty jar file in my project which is not fit in repository.

(如果您要的是我,只要不删除该功能,就可以使用它来仅依赖项目中一个调皮的jar文件 ,该文件不适合存储库。)

If this feature is removed, well, there are lots of good answers here which I can chose from later!

(如果此功能被删除,那么,这里有很多好的答案,我以后可以选择!)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...