私服的使用


本地 maven settings.xml 配置
 <mirrors>
  
	<mirror>  
      <!--This sends everything else to /public -->  
      <id>nexus</id>  
      <mirrorOf>*</mirrorOf>  
      <url>http://192.168.1.106:8082/nexus/content/groups/public/</url>  
    </mirror> 
  
  </mirrors>
复制代码
<servers>
   <server>
       <id>releases</id>
       <username>admin</username>
       <password>admin123</password>
   </server>
   <server>
       <id>snapshots</id>
       <username>admin</username>
       <password>admin123</password>
   </server>
</servers>
复制代码
<profiles>
	<profile>  
      <id>nexus</id>  
      <!--Enable snapshots for the built in central repo to direct -->  
      <!--all requests to nexus via the mirror -->  
		<repositories>  
			<repository>  
			  <id>central</id>  
			  <url>http://central</url>  
			  <releases><enabled>true</enabled><updatePolicy>always</updatePolicy></releases>  
			  <snapshots><enabled>true</enabled></snapshots>  
			</repository>  
			<repository>  
				<id>spring-release</id>  
				<name>Spring Maven Release Repository</name>  
				<url>http://repo.springsource.org/libs-release</url>  
				<snapshots>  
					<enabled>false</enabled>  
				</snapshots>  
			</repository>  
		</repositories>  
		<pluginRepositories>  
			<pluginRepository>  
			  <id>central</id>  
			  <url>http://central</url>  
			  <releases><enabled>true</enabled><updatePolicy>always</updatePolicy></releases>  
			  <snapshots><enabled>true</enabled></snapshots>  
			</pluginRepository>  
      </pluginRepositories>  
    </profile>
  </profiles>

<!--激活id为nexus的profile-->
<activeProfiles> 
&emsp;<activeProfile>nexus</activeProfile> 
</activeProfiles>
复制代码
项目pom.xml文件配置
  • xml 中添加如下配置:
<!--发布自己的项目到 私服-->
    <distributionManagement>
        <repository>
            <id>releases</id> <!--这里的id与 maven config sttings.xml server 中配置的id要一致-->
            <name>Nexus Release Repository</name>
            <url>http://192.168.1.106:8082/nexus/content/repositories/releases/</url>
        </repository>
        <snapshotRepository>
            <id>snapshots</id><!--这里的id与 maven config sttings.xml server 中配置的id要一致-->
            <name>Nexus Snapshot Repository</name>
            <url>http://192.168.1.106:8082/nexus/content/repositories/snapshots/</url>
        </snapshotRepository>
    </distributionManagement>
复制代码

系统会根据你当前项目是 releases 版本还是 snapshots 上传到指定的私服位置,如: <version>1.0-SNAPSHOT</version> 即为 snapshots 版, <version>1.0</version> 为 发行版(releases)。

  • 通过maven 命令发布到私服 mvn deploy, 也可通过图像界面发布,根据自己的喜好。 1.eclipse 建立 maven deploy 选项(IDEA自带有):右击项目,依次执行:Run As --> Run Configurations ---> Maven Build --->New _Configuration(双击Maven Build可生成) --> Browse Workspace 选中项目,Goals输入 : deploy -e 后,点击 Run。

  • 引用公司发布的项目可登录nexus 后复制引用 dependency,如下图位置:

私服访问地址:http://192.168.1.106:8082/nexus/

点击右上角log in : username:admin password:admin123

转载于:https://juejin.im/post/5af25bcef265da0b814b8748

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值