使用Nexus从私服上传和下载依赖

从私服中下载依赖

【第一步】在maven的settings.xml中标签中配置,此时就需要注释掉aliyun的配置。

<mirror>
    <id>nexus-heimaid>
    <mirrorOf>*mirrorOf>
    <url>http://localhost:8081/repository/maven-public/url>
mirror>

【第二步】在nexus中设置允许匿名下载,如果不允许将不会从私服中下载依赖使用Nexus从私服上传和下载依赖_第1张图片
如果私服中没有对应的jar,会去中央仓库下载,速度很慢。可以配置让私服去阿里云中下载依赖。

使用Nexus从私服上传和下载依赖_第2张图片

从私服中上传依赖

【第一步】配置本地仓库访问私服的权限(在maven的settings.xml的servers标签中配置)

<server>
  
  <id>heima-nexusid>
  <username>adminusername>
  <password>123456password>
server>

【第二步】配置当前项目访问私服上传资源的保存位置(项目的pom.xml文件中配置)

<distributionManagement>
    <repository>
      	
        <id>heima-nexusid>
      	
        <url>http://localhost:8081/repository/heima-releases/url>
    repository>
    <snapshotRepository>
      	
        <id>heima-nexusid>
      	
        <url>http://localhost:8081/repository/heima-snapshots/url>
    snapshotRepository>
distributionManagement>

要和maven的settings.xml中server中定义的heima-nexus对应

【第三步】发布资源到私服命令

mvn deploy

你可能感兴趣的:(java,服务器)