Home > Java > javaTutorial > How to solve the problem that maven cannot download dependent jar packages (example explanation)

How to solve the problem that maven cannot download dependent jar packages (example explanation)

不言
Release: 2019-03-15 13:16:23
forward
6106 people have browsed it

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>
Copy after login

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]
Copy after login

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>
Copy after login

The label is the update policy, always Always download the latest dependencies in the repository.
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!

Related labels:
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template