saowu's Blog

关于maven-deploy-plugin与-DaltDeploymentRepository参数

关于maven-deploy-plugin与-DaltDeploymentRepository参数
2022-04-12 · 2 min read
Maven Java

记录一次问题

一位开发遇到了一个问题:如果此处<distributionManagement><repository><id>不存在于settings.xml将会发生错误。

    <!-- 用于上传远程maven私服的配置 -->
    <distributionManagement>
        <repository>
            <id>releases</id>
            <url>http://url/repository/releases/</url>
        </repository>
        <snapshotRepository>
            <id>snapshots</id>
            <url>http://url/repository/snapshots/</url>
        </snapshotRepository>
    </distributionManagement>
   <!-- settings.xml -->
    <server>
        <id>releases</id>
        <username>user</username>
        <password>pwd</password>
    </server>  
    <server>
        <id>snapshots</id>
        <username>user</username>
        <password>pwd</password>
    </server>

解决方法有两种:

  • 修改<distributionManagement><repository><id>
  • 注释掉pom.xml中<distributionManagement>配置
    • 已默认追加-DaltSnapshotDeploymentRepository-DaltReleaseDeploymentRepository

当我走第二种方案时,但是未解决问题并出现一下提示。

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

原因:maven-deploy-plugin.version = 2.7不支持该参数。使用2.8+即可。

其他:-am 参数使用

  • 参数:mvn deploy -am
  • 比如:当你选择一个模块发布,由于加了-am,maven它会把依赖的包也发布上去。如果不加-am参数,当依赖的包版本在本地和远程仓库都找不到,就会打包失败。
Copyright © 2020 - 2024 saowu. All Right Reserved
Powered by Gridea