将jar deploy到私服nexus常见问题

版权声明:版权声明:本文为博主原创文章,欢迎转载,转载请注明作者、原文超链接 https://blog.csdn.net/qq_35098526/article/details/85055810

一.出现:Cannot deploy artifacts when Maven is in offline mode -> [Help 1]

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project acpe-common: Cannot deploy artifacts when Maven is in offline mode -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
在这里插入图片描述

解决办法:原因是intellij IDEA 默认为offline模式,进入Settings,把Work offline的勾去除即可。

二.Return code is: 401, ReasonPhrase: Unauthorized. -> [Help 1]

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project acpe-common: Failed to deploy artifacts: Could not transfer artifact com.****0.1-20181217.122106-8.jar. Return code is: 401, ReasonPhrase: Unauthorized. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
在这里插入图片描述
解决办法:
1.检查pom.xml、setting.xml 对应nexus账号密码是否错误。
2.检查pom.xml、setting.xml 对应url地址是否正确。

三.出现: Return code is: 400, ReasonPhrase: Repository does not allow updating assets: maven-releases.

搜集一些报400的原因:
1.nexus的repository分三种类型:Hosted、 Proxy和Virtual,另外还有一个repository group(仓库组)用于对多个仓库进行组合。部署的时候只能部署到Hosted类型的仓库中,如果是其他类型就会出现这个400错误。
2.默认情况下部署构件到Releases仓库中有时也会出现400错误,这个原因就像上面提到的那样,Nexus中 Releases仓库默认的Deployment Policy是“Disable Redeploy”,
所以无论你在settings.xml文件中将server的username设置为deployment还是使用admin都是无 法部署的,就会出现这个400错误。
3.Nexus中 Releases仓库Respository PolicySnapshot是“Release”
Snapshot仓库Respository PolicySnapshot是“Snapshot” 如果设置反了或错了也是无法部署的。
4.如果你Snapshot可以发布,但是releases却发布不了,可能是1.0-SNAPSHOT类似这样的,version中包含了-SNAPSHOT,所以release发布不了, 也会返回400错误。

在这里插入图片描述
解决办法:在nexus的maven-releases设置为Allow redeploy(可重复提交)即可

4.出现:Compilation failure: Compilation failure (编译失败)

解决办法:
因为jdk版本的升级导致一些api已经失效,解决的办法有很多,最好的办法是在pom.xml文件中加入如下配置(通过配置maven-compiler-plugin插件解决此问题):
`

   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-compiler-plugin</artifactId>
   <configuration>
       <source>1.8</source>
       <target>1.8</target>
       <testSource>1.8</testSource>
       <testTarget>1.8</testTarget>
       <encoding>utf-8</encoding>
       <compilerArguments>
           <verbose />
     <bootclasspath>${java.home}/lib/rt.jar;${java.home}/lib/jce.jar</bootclasspath>
       </compilerArguments>
   </configuration> </plugin>

`

猜你喜欢

转载自blog.csdn.net/qq_35098526/article/details/85055810