maven deploy时报错的解决方法

所属分类: 软件编程 / java 阅读数: 81
收藏 0 赞 0 分享

今天在发布maven工程的时候,很奇怪,因为在本地package,install等等都没问题,但是打包的时候就是报错,日志如下:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project courier-rapi: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project courier-rapi: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter
        at org.apache.maven.plugin.deploy.DeployMojo.getDeploymentRepository(DeployMojo.java:235)
        at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:118)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        ... 20 more
[ERROR]

如果对于maven不太熟悉的同学会很苦恼,仔细看日志我们会发现如下的信息:

repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter

意思是在pom文件中缺少distributionManagement标签,或者缺少-DaltDeployementRepositoty,说的是缺少deploy的地址,maven不知道你想要deploy到哪里,在pom文件中增加如下信息,就发布成功了.

<distributionManagement>
    <repository>
      <id>nexus</id>
      <name>releases</name>
      <url>http://mvn2.qdingnet.com/nexus/content/repositories/releases</url>
      <uniqueVersion>true</uniqueVersion>
    </repository>
    <snapshotRepository>
      <id>nexus</id>
      <name>snapshots</name>
      <url>http://XXXXXXXXXXXXX/nexus/content/repositories/snapshots</url>
    </snapshotRepository>
  </distributionManagement>

为了补充知识,下面讲解一下关于distributionManagement及其配置的信息.

用于配置分发管理,配置相应的产品发布信息,主要用于发布,在执行mvn deploy后表示要发布的位置,下面时几种配置形式.

配置到文件系统

<distributionManagement>
  <repository>
    <id>proficio-repository</id>
    <name>Proficio Repository</name>
    <url>file://${basedir}/target/deploy</url>
  </repository>
</distributionManagement>

使用ssh2配置

<distributionManagement>
  <repository>
    <id>proficio-repository</id>
    <name>Proficio Repository</name>
    <url>scp://sshserver.yourcompany.com/deploy</url>
  </repository>
</distributionManagement>

使用sftp配置

<distributionManagement>
  <repository>
    <id>proficio-repository</id>
    <name>Proficio Repository</name>
    <url>sftp://ftpserver.yourcompany.com/deploy</url>
  </repository>
</distributionManagement>

使用外在的ssh配置

<distributionManagement>
  <repository>
    <id>proficio-repository</id>
    <name>Proficio Repository</name>
    <url>scpexe://sshserver.yourcompany.com/deploy</url>
  </repository>
</distributionManagement>
<build>
  <extensions>
    <extension>
      <groupId>org.apache.maven.wagon</groupId>
      <artifactId>wagon-ssh-external</artifactId>
      <version>1.0-alpha-6</version>
    </extension>
  </extensions>
</build>

使用ftp配置

<distributionManagement>
  <repository>
    <id>proficio-repository</id>
    <name>Proficio Repository</name>
    <url>ftp://ftpserver.yourcompany.com/deploy</url>
  </repository>
</distributionManagement>
<build>
  <extensions>
    <extension>
      <groupId>org.apache.maven.wagon</groupId>
      <artifactId>wagon-ftp</artifactId>
      <version>1.0-alpha-6</version>
    </extension>
  </extensions>
</build>
更多精彩内容其他人还在看

Javaweb 鼠标移入移出表格颜色变化的实现

这篇文章主要介绍了Javaweb 鼠标移入移出表格颜色变化的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
收藏 0 赞 0 分享

Java 实现图片压缩的两种方法

这篇文章主要介绍了Java 实现图片压缩的两种方法,帮助大家更好的理解和使用Java,感兴趣的朋友可以了解下
收藏 0 赞 0 分享

据说这个是可以撸到2089年的idea2020.2(推荐)

这篇文章主要介绍了据说这个是可以撸到2089年的idea2020.2,本教程给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
收藏 0 赞 0 分享

一篇文章带你搞定SpringBoot不重启项目实现修改静态资源

这篇文章主要介绍了一篇文章带你搞定SpringBoot不重启项目实现修改静态资源,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
收藏 0 赞 0 分享

win10操作系统下重启电脑java环境变量失效

这篇文章主要介绍了win10操作系统下重启电脑java环境变量失效,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
收藏 0 赞 0 分享

Java实现批量修改文件名和重命名的方法

这篇文章主要介绍了Java实现批量修改文件名和重命名的方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
收藏 0 赞 0 分享

关于Java HashMap自动排序的简单剖析

这篇文章主要给大家介绍了关于Java HashMap自动排序的简单剖析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
收藏 0 赞 0 分享

Spring中BeanFactory和ApplicationContext的作用和区别(推荐)

这篇文章主要介绍了Spring中BeanFactory和ApplicationContext的作用和区别,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
收藏 0 赞 0 分享

Java程序执行Cmd指令所遇问题记录及解决方案

这篇文章主要介绍了Java程序执行Cmd指令所遇问题记录,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
收藏 0 赞 0 分享

深入浅析jni中的java接口使用

这篇文章主要介绍了jni中的java接口使用,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
收藏 0 赞 0 分享
查看更多