如何将公共存储库(例如 Maven Central)中的工件缓存到私有的 Nexus 存储库?

gle*_*986 5 eclipse nexus maven

基本上,我问的问题与此处链接的问题相同。

但是,我不认为所选择的答案解决了问题。另外,前一个是几年前问过的。

我安装的Nexus OSS版本是2.11.2-06(最新版本)。

如果我使用 Nexus GUI 进行搜索并单击下载按钮,我可以缓存工件。 Nexus 图形用户界面

但是,如果我在 eclipse 的 pom 文件中声明工件,则它不会被缓存。它只会从 MAVEN CENTRAL 获取它并将其缓存在我的计算机本地,但不会缓存在 Nexus 存储库中。

我希望当我在 Eclipse 中的 POM 文件中声明依赖项时,如果它没有本地缓存​​,maven 将从 MAVEN CENTRAL 获取它,并将其本地缓存在我的计算机和 Nexus 存储库中。

我的maven settings.xml如下所示:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<profiles>
    <profile>
        <id>kingstar-internal</id>
        <repositories>
            <repository>
                <id>kingstar-internal-repository</id>
                <name>Kingstar Internal Repository</name>
                <url>http://localhost:8081/nexus/content/repositories/KingstarRepository</url>
            </repository>
            <repository>
                <id>kingstar-snapshot-repository</id>
                <name>Kingstar Snapshot Repository</name>
                <url>http://localhost:8081/nexus/content/repositories/KingstarSnapshotRepository</url>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </repository>
        </repositories>
    </profile>
</profiles>

<mirrors>
<mirror>
  <id>public-mirror</id>
  <mirrorOf>*</mirrorOf>
  <name>public mirror</name>
  <url>http://localhost:8081/nexus/content/groups/public/</url>
</mirror>
</mirrors>

<activeProfiles>
    <activeProfile>kingstar-internal</activeProfile>
</activeProfiles>

<servers>
    <server>
        <id>kingstar-internal-repository</id>
        <username>deployment</username>
        <password>deployment</password>
    </server>
    <server>
        <id>kingstar-snapshot-repository</id>
        <username>deployment</username>
        <password>deployment</password>
    </server>
</servers>
</settings>
Run Code Online (Sandbox Code Playgroud)

任何帮助表示赞赏!