简体   繁体   English

将本地 jar 作为依赖项添加到 Maven 项目

[英]Adding local jar as dependency to maven project

I have maven project where i need to add local jar as the dependency.我有 maven 项目,我需要在其中添加本地 jar 作为依赖项。

I have stored my jar into my maven folder using:我已使用以下方法将 jar 存储到我的 Maven 文件夹中:

mvn install:install-file -Dfile=path\\to\\file\\framework-0.0.0.1-SNAPSHOT.jar -DgroupId=test -DartifactId=test -Dversion=0.0.0.1 -Dpackaging=jar -DgeneratePom=true

I have read that adding dependencty to POM file is deprecated ( didnt even work for me ).我已经读过向 POM 文件添加依赖项已被弃用(甚至对我不起作用)。 So how should i include this dependency in my project?那么我应该如何在我的项目中包含这个依赖项? My settings.xml looks like:我的 settings.xml 看起来像:

<localRepository>C:\project\.m2</localRepository>
<mirrors>
       ....
</mirrors>

<servers>
    <server>
         ....
    </server>
    <server>
        ....
    </server>
</servers>

If i try to jusat use classes from the jar, Intelijj cannot find.如果我尝试使用 jar 中的类,Intelijj 将找不到。 So how should i add this dependency to my maven project?那么我应该如何将此依赖项添加到我的 maven 项目中呢?

Thanks for answers感谢您的回答

You installed the dependency in the local repository.您在本地存储库中安装了依赖项。

So you can use it as any other dependency by declaring it as <dependency> in the <dependencies> area of your pom.xml .因此,您可以通过在pom.xml<dependencies>区域中将其声明为<dependency>来将其用作任何其他依赖项。

BTW: Don't use system scope.顺便说一句:不要使用系统范围。

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

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