The content of this article is about how to solve the virtual problem that Maven cannot download dependent jar packages (example explanation). It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
The company has built a maven private server internally, and made a core jar package. The first version is xxx-core.1.0.0.SNAPSHOT, which can be used normally in both local and project environments. To support the launch, a stable version, xxx-core.1.0.0.jar, is released.
Local compilation is normal, startup is normal, project environment, when gitlab is automatically deployed to Rancher after submission, I find that the jar package cannot be downloaded.
Repository configuration of pom.xml file:
<repositories> <repository> <id>xxxxx.releases</id> <name>Releases</name> <url>https://nexus.xxxxxx.com/repository/maven-releases</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> <repository> <id>xxxxxx.snapshots</id> <name>Snapshot</name> <url>https://nexus.huilianyi.com/repository/maven-snapshots</url> <releases> <enabled>false</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository></repositories>
Maven error message when compiling:
Failed to execute goal on project service: Could not resolve dependencies for project com.xxxxx:service:war:1.0-SNAPSHOT: Failure to find com.xxxxx-core:jar:1.0.0 in https://nexus.xxxx.com/repository/maven-releases was cached in the local repository, resolution will not be reattempted until the update interval of xxx.releases has elapsed or updates are forced -> [Help 1]
The prompt is that the id of the repository configured in the private library: xxx.releases has a cache update interval. Before this update time, the jar is obtained from the cache, so it is newly uploaded to the warehouse xxx The jar package -core.1.0.0.jar is not in the cache
, so it is not pulled down.
Solution:
pom.xml changed to:
<repositories> <repository> <id>xxxxx.releases</id> <name>Releases</name> <url>https://nexus.xxxxxx.com/repository/maven-releases</url> <releases> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> <repository> <id>xxxxxx.snapshots</id> <name>Snapshot</name> <url>https://nexus.huilianyi.com/repository/maven-snapshots</url> <releases> <enabled>false</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository></repositories>
Note: After pulling it down, you need to remove this configuration, otherwise you will have to download the jar package every time, which is very time-consuming to compile.
The above is the detailed content of How to solve the problem that maven cannot download dependent jar packages (example explanation). For more information, please follow other related articles on the PHP Chinese website!