---
title: "maven 组件发布配置"
author: "1028826685"
date: "2018-06-26T17:28:59Z"
tags: []
categories: ["互联网"]
slug: "maven"
draft: false
lastmod: "2018-06-26T17:28:59Z"
id: 2425647
url: "https://1028826685.iteye.com/blog/2425647"
---

### 1. 在要发布到maven私服的项目pom.xml加入下面配置

 

 

`<distributionManagement>`

`<repository>`

`<id>huwo-local-releases</id>`

`<name>local-releases</name>`

`<url>http://bin.huwo.io/artifactory/libs-release-local</url>`

`</repository>`

`<snapshotRepository>`

`<id>huwo-local-snapshots</id>`

`<name>local snapshots</name>`

`<url>http://bin.huwo.io/artifactory/libs-snapshot-local</url>`

`</snapshotRepository>`

`</distributionManagement>`

当项目版本号后面带 **-SNAPSHOT** 的时候，会发布到 **libs-snapshot-local** 库，如果不带，会发布到 **libs-release-local** 库

### 2. 本地settings.xml文件加入server相关帐号密码配置

 

`<servers>`

`<server>`

`<id>huwo-local-releases</id>`

`<username>release</username>`

`<password>xxxxxx</password>`

`</server>`

`<server>`

`<id>huwo-local-snapshots</id>`

`<username>release</username>`

`<password>xxxxxxx</password>`

`</server>`

`</servers>`

 

# 使用私有库组件配置

在项目的pom.xml文件中加入下面配置

 

`<repositories>`

`<repository>`

`<id>huwo-local-releases</id>`

`<name>Local repository</name>`

`<url>http://xxx/artifactory/libs-release-local</url>`

`<releases><enabled>true</enabled></releases>`

`<snapshots>`

`<enabled>false</enabled>`

`</snapshots>`

`</repository>`

`<repository>`

`<id>huwo-local-snapshot</id>`

`<name>Local repository</name>`

`<url>http://xxx/artifactory/libs-snapshot-local</url>`

`<snapshots>`

`<enabled>true</enabled>`

`</snapshots>`

`</repository>`

`</repositories>`

 

maven会根据不同的依赖组件版本到不同库中下载组件