maven deploy時報錯的解決方法
今天在釋出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 parameterat 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>
到此這篇關於maven deploy時報錯的解決方法的文章就介紹到這了,更多相關maven deploy報錯內容請搜尋我們以前的文章或繼續瀏覽下面的相關文章希望大家以後多多支援我們!