Java maven 全新安装不从本地存储库中获取 jar

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20852946/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 04:48:14  来源:igfitidea点击:

maven clean install not taking jar from local repository

javamavencommand-prompt

提问by

I am trying to run mvn clean installcommand from command line. At one location it is trying to download the jar from remote location.

我正在尝试从命令行运行mvn clean install命令。在一个位置,它试图从远程位置下载 jar。

[INFO] Deleting directory C:\Users2368997\ruchita_pdm_laptop\vobs\iui\src\newsrc\xr-service-impl\target
[INFO] [resources:resources]
[INFO] Using 'ISO-8859-1' encoding to copy filtered resources.
[INFO] Copying 0 resource
Downloading:     http://3.204.29.172:8081/artifactory/repo1/com/gehc/xr/wf/DuifEventsData/1.0.0-SNAPSHOT/DuifEventsData-1.0.0-SNAPSHOT.jar
[WARNING] Unable to get resource 'com.gehc.xr.wf:DuifEventsData:jar:1.0.0-SNAPSHOT'  from repository xr-workflow-repository (http://3.204.29.172:8081/artifactory/repo
1): Error transferring file: Connection timed out: connect
Downloading:     http://3.204.29.172:8081/artifactory/repo1/com/gehc/xr/wf/DuifEventIdVal/1.0.0-  SNAPSHOT/DuifEventIdVal-1.0.0-SNAPSHOT.jar

and the process halts. I have

并且过程停止。我有

DuifEventsData-1.0.0-SNAPSHOT.jar

DuifEventsData-1.0.0-SNAPSHOT.jar

jar at the local repository in .m2 folder then also it is trying to download the jar from [(http://3.204.29.172:8081/...]
what is the solution for this ?

.m2 文件夹中本地存储库中的 jar 文件,然后它也试图从 [(http://3.204.29.172:8081/...] 下载 jar 文件
,对此有什么解决方案?

采纳答案by gowtham

Try running maven offline mvn clean install -o. This will pick jars from your local repository i.e in .m2. As you mentioned jar is already in local repo, and if all other dependencies are also in local, this will work.

尝试运行 Maven 离线mvn clean install -o。这将从您的本地存储库中选择 jars,即 .m2。正如您提到的 jar 已经在本地仓库中,如果所有其他依赖项也在本地,这将起作用。

回答by Vineet Kasat

Please check your settings.xml in .m2 folder.

请检查 .m2 文件夹中的 settings.xml。

回答by Amila

Make sure the remote repository is not defined in your project POM under or in $MAVEN_HOME/conf/settings.xml

确保在 $MAVEN_HOME/conf/settings.xml 下或中的项目 POM 中未定义远程存储库

回答by Yx.Ac

maybe the jar shouldn't be placed in .m2 folder, it should be placed in where it should be. Please use mvn -X to print debug information, maybe some clues would be found.

也许罐子不应该放在 .m2 文件夹中,它应该放在它应该放在的地方。请使用 mvn -X 打印调试信息,也许会找到一些线索。

回答by dhamibirendra

When snapshot depedencies are used, maven checks stable or updated depedencies.And that is what happening in your casse. In you repository config in pom.xml you need to set updaate policy for Snapshot as:

使用快照依赖项时,maven 检查稳定或更新的依赖项。这就是您的案例中发生的情况。在 pom.xml 中的存储库配置中,您需要将快照的更新策略设置为:

<repository>
    <id>a-repository</id>
    <url>http://3.204.29.172:8081/artifactory/repo</url>
    <snapshots>
        <enabled>true</enabled>
        <updatePolicy>never</updatePolicy>
    </snapshots>
</repository>

<updatePolicy>never</updatePolicy>.. This will disable the check and download for snapshot dependency

<updatePolicy>never</updatePolicy>.. 这将禁用快照依赖项的检查和下载

For more details refer

有关更多详细信息,请参阅