繁体   English   中英

如何强制 Maven 使用外部存储库来检索工件?

[英]How do I force Maven to use external repos to retrieve artifacts?

尝试构建项目时出现以下错误。 该项目是 spring 项目并使用 IntelliJ 和 java 8。

Could not find artifact org.springframework.data:spring-data-bom:pom:2021.0.0-M2 in nexus (http://maven:8081/nexus/content/groups/public)

有没有办法通过setting.xml修复它? 我无法访问 http://maven:8081/nexus/content/groups/public 上的任何配置

这是我的设置。

<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">

<servers>
    <server>
        <id>releases</id>
        <username>me</username>
        <password>mee</password> <!-- impossible password here :-) -->
    </server>
    <server>
        <id>snapshots</id>
        <username>me</username>
        <password>mee</password> <!-- impossible password here :-) -->
    </server>
    <server>
        <id>nexus</id>
        <username>me</username>
        <password>mee</password> <!-- impossible password here :-) -->
    </server>
</servers>

<mirrors>
    <mirror>
        <!--This sends everything else to /public -->
        <id>nexus</id>
        <mirrorOf>*</mirrorOf>
        <url>http://maven:8081/nexus/content/groups/public</url>
    </mirror>
</mirrors>

<profiles>
    <profile>
        <id>nexus</id>
        <!--Enable snapshots for the built in central repo to direct -->
        <!--all requests to nexus via the mirror -->

        <repositories>
            <repository>
                <id>central</id>
                <url>https://mvnrepository.com/repos/central</url>
                <releases><enabled>true</enabled><updatePolicy>always</updatePolicy></releases>
                <snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots>
            </repository>
        </repositories>

        <pluginRepositories>
            <pluginRepository>
                <id>central</id>
                <url>https://mvnrepository.com/repos/central</url>
                <releases><enabled>true</enabled><updatePolicy>always</updatePolicy></releases>
                <snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots>
            </pluginRepository>
        </pluginRepositories>
    </profile>

    <profile>
        <id>defaultprofile</id>
        <!-- if you want to be able to switch to the defaultprofile profile put this in the active profile -->

        <repositories>
            <repository>
                <id>maven.default</id>
                <name>default maven repository</name>
                <url>http://repo1.maven.org/maven2</url>
                <releases><enabled>true</enabled><updatePolicy>always</updatePolicy></releases>
                <snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots>
            </repository>
            <repository>
                <id>maven.snapshot</id>
                <name>Maven snapshot repository</name>
                <releases><enabled>true</enabled><updatePolicy>always</updatePolicy></releases>
                <url>http://people.apache.org/repo/m2-snapshot-repository</url>
                <snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots>
            </repository>
            <repository>
                <id>vaadin-addons</id>
                <url>https://maven.vaadin.com/vaadin-addons</url>
            </repository>
        </repositories> 
    </profile>
</profiles>

<activeProfiles>
    <!--make the profile active all the time -->
    <activeProfile>nexus</activeProfile>
</activeProfiles>

如果你设置

    <mirrorOf>*</mirrorOf>
    <url>http://maven:8081/nexus/content/groups/public</url>

然后您将每个请求发送到此存储库,无论settings.xml的 rest 是什么。 你需要做类似的事情

    <mirrorOf>*,!central</mirrorOf>
    <url>http://maven:8081/nexus/content/groups/public</url>

但也请更正/删除 khmarbaise 所说的 URL。

暂无
暂无

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

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