1.jar包下载失败,导致生成lastUpdated文件
第一次因为没有联网或者或者其它原因,导致下载jar失败,以后依然下载失败。
原因 : 因为第一次下载失败时,会在~\.m2\repository 中生成对应jar包的lastUpdated文件,如xxx.jar.lastUpdated,
因为有这个lastUpdated文件,所以以后都不会真正下载xxx.jar.lastUpdated。 <br>
解决方法:
1. 在执行mvn <commond>之前把lastUpdated 文件删除
2. 直接拷贝一个jar到此目录下
2.Maven缺少依赖包,强制更新
mvn clean install -e -U
-e详细异常,-U强制更新
3.mvn deploy
- 要直接上传jar,必须在主pom中添加对应的repository
<distributionManagement>
<repository>
<id>releases</id>
<name>Nexus Release Repository</name>
<url>your releases repositories url</url>
</repository>
<snapshotRepository>
<uniqueVersion>false</uniqueVersion>
<id>snapshots</id>
<name>Nexus Snapshot Repository</name>
<url>your snapshot repositories url</url>
</snapshotRepository>
</distributionManagement>
- 如果只想上传jar,不想上传war
在不想上传的工程pom里面添加
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
- 如果想单独上传某个jar
mvn deploy:deploy-file -DgroupId={groupId} -DartifactId={artifactId} -Dversion={version} -Dpackaging=jar -Dfile={path} -Durl={your repository url} -DrepositoryId={your repository id}
DgroupId和DartifactId构成了该jar包在pom.xml的坐标
Dfile表示需要上传的jar包的绝对路径
Durl私服上仓库的位置,打开nexus——>repositories菜单,可以看到该路径。
DrepositoryId服务器的表示id,在nexus的configuration可以看到。
Dversion表示版本信息,怎样得到一个jar包准确的版本呢?
如果单独上传某个jar,而项目为多模块的时候,开发新的迭代版本的时候,更新了一下新版本的jar,同时更新了父模块的版本号,此时必须把父模块的pom.xml deploy到私服上,否则报错。 **因为** 子模块的打包方式为jar,父模块的打包方式 为pom,,子模块依赖于父模块,所以会报错。
如果报错,极有可能是url或者repositoryId写错了
Access denied to: {}.jar, ReasonPhrase: Forbidden.
检查是否缺少权限,在 .m2/settings.xml中配置权限
作者:glowd
原文:https://blog.csdn.net/zengqiang1/article/details/52841090
版权声明:本文为博主原创文章,转载请附上博文链接!