Maven:在 distributionManagement 内部的 POM 中未指定存储库元素?

标签 maven

我正在尝试运行命令 mvn release:perform,但出现此错误:

Failed to execute goal
org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy
(default-deploy) on project git-demo:
Deployment failed: repository element
was not specified in the POM inside
distributionManagement element or in
-DaltDeploymentRepository=id::layout::url
parameter

这是我的 pom.xml 文件:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.sonatype.blog</groupId>
    <artifactId>git-demo</artifactId>
    <packaging>jar</packaging>
    <version>1.1-SNAPSHOT</version>
    <name>git-demo</name>
    <url>http://maven.apache.org</url>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <scm>
        <connection>scm:git:git@github.com:Christian-Achilli-KP/git-demo.git</connection>
        <url>scm:git:git@github.com:Christian-Achilli-KP/git-demo.git</url>
        <developerConnection>scm:git:git@github.com:Christian-Achilli-KP/git-demo.git</developerConnection>
    </scm>

    <distributionManagement>
        <!-- use the following if you're not using a snapshot version. -->
        <repository>
            <id>localSnap</id>
            <name>RepositoryProxyRel</name>
            <url>http://127.0.0.1:8080/nexus/content/repositories/releases/</url>
        </repository>
        <!-- use the following if you ARE using a snapshot version. -->
        <snapshotRepository>
            <id>MylocalSnap</id>
            <name>RepositoryProxySnap</name>
            <url>http://127.0.0.1:8080/nexus/content/repositories/snapshots/</url>
        </snapshotRepository>
    </distributionManagement>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.1</version>
            </plugin>
        </plugins>
    </build>
</project>

其实我可以看到

repository

里面的声明

distributionManagent

标签。

这是我的settings.xml:

<settings>
    <servers>
        <server>
            <id>localSnap</id>
            <username>deployment</username>
            <password>****</password>
        </server>

        <server>
            <id>MylocalSnap</id>
            <username>deployment</username>
            <password>****</password>
        </server>

        <server>
            <id>myserver</id>
            <username>tomcat</username>
            <password>tomcat</password>
        </server>
    </servers>
    <mirrors>
        <mirror>
            <!--This sends everything else to /public -->
            <id>nexus</id>
            <mirrorOf>*</mirrorOf>
            <url>http://127.0.0.1:8080/nexus/content/groups/public/</url>
        </mirror>
    </mirrors>
    <profiles>
        <profile>
            <id>nexus</id>
            <properties>
                <project.build.sourceEncoding>MacRoman</project.build.sourceEncoding>
                <project.reporting.outputEncoding>MacRoman</project.reporting.outputEncoding>
            </properties>

            <!--Enable snapshots for the built in central repo to direct -->
            <!--all requests to nexus via the mirror -->
            <repositories>
                <repository>
                    <id>central</id>
                    <url>http://central</url>
                    <releases><enabled>true</enabled></releases>
                    <snapshots><enabled>true</enabled></snapshots>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>central</id>
                    <url>http://central</url>
                    <releases><enabled>true</enabled></releases>
                    <snapshots><enabled>true</enabled></snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>

    <activeProfiles>
        <activeProfile>nexus</activeProfile>
    </activeProfiles>

</settings>

有什么建议为什么会提示吗?

最佳答案

查看 target/checkout/ 中的 pom.xml 文件。很可能,您的主干或主分支中的 pom.xml 没有 distributionManagement 标记。

关于Maven:在 distributionManagement 内部的 POM 中未指定存储库元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38709456/

相关文章:

java - 为什么我无法在 Android 项目中使用 Maven 存储库中的库?如何为此编写正确的pom.xml?

java - 找不到 Apache Camel maven 项目 addRouteBuilder

maven - Maven 是否支持此应用程序设置?

java - 是什么让 Maven 希望在 Spring Boot 项目中使用 openjfx 和 Zulu Java 11 而不是 Zulu Java 8?

java - 在没有项目的情况下执行 Maven 目标

maven - 无法从 Maven 测试单元中调用 sun.security.tools.keytool.Main

java - 使用Maven构建的Docker镜像看不到静态文件

spring - 如何为 SQLite 配置相关数据源文件?

java - Spring - 缺少必需的库 - hibernate3-3.2.3.GA.jar

java - Maven 将两个单独的目录及其文件复制到不同的位置