1. settings.xml配置
<!-- 在<servers>标签内新增 -->
<server>
<id>nexus-maven-release</id>
<username>admin</username>
<password>123123</password>
</server>
<server>
<id>nexus-maven-snapshot</id>
<username>admin</username>
<password>123123</password>
</server>
2. 项目pom.xml配置
<distributionManagement>
<repository>
<id>nexus-maven-release</id>
<name>nexus-release</name>
<url>http://192.168.18.52:8081/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>nexus-maven-snapshot</id>
<name>nexus-snapshot</name>
<url>http://192.168.18.52:8081/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
然后执行mvn deploy
在maven-public仓库中可以看到上传的jar
问题记录
执行mvn mybatis-generator:generate
出现无法下载org.apache.maven.plugins插件
Failure to find org.mybatis.generator:mybatis-generator-maven-plugin:jar:1.4.0 in http://{nexusIP}:8081/repository/maven-public/ was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced
解决方式:
使用 mvn clean package -U 打包即可(注意:出于性能原因,Maven缓存插件无法下载的信息。根据您的设置,您可能需要通过将标志添加-U到命令行来清除此缓存,以使更正生效)
deploy示例
mvn deploy:deploy-file -Dfile=jvppeteer-1.1.3.jar -DgroupId=io.github.fanyong920 -DartifactId=jvppeteer -Dversion=1.1.3 -Dpackaging=jar -DrepositoryId=nexus-maven-release -Durl=http://{nexusHost}:8081/repository/maven-releases/
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。