---
title: "无法下载maven私库中项目的问题"
author: "lfwer"
date: "2018-11-09T11:18:52Z"
tags: []
categories: ["编程语言"]
slug: "maven"
draft: false
lastmod: "2018-11-09T11:20:47Z"
id: 2433546
url: "https://lfwer.iteye.com/blog/2433546"
---

最近着手将项目拆分为了多个子项目，首先建立了一个父项目用于管理所有maven依赖包，接着做了两个工具jar，再就是几个业务项目。父项目和工具jar都上传到了公司私库，后来其他同事反应无法下载。通过调试发现，需要在业务项目中配置私库才能下载。

 

父项目中配置私库

```
<distributionManagement>
        <repository>
            <id>g7-release</id>
            <url>http://xx.com/artifactory/libs-release-local</url>
        </repository>
        <snapshotRepository>
            <id>g7-snapshots</id>
            <url>http://xx.com/artifactory/libs-snapshot-local</url>
        </snapshotRepository>
    </distributionManagement>
```

 

工具jar和业务项目配置私库

```
<repositories>
        <repository>
            <id>g7-central</id>
            <url>http://xx.com/artifactory/libs-release</url>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
            </snapshots>
        </repository>
    </repositories>
```

 

如果要执行deploy，需要在setting.xml中配置你的私库账号

```
<server>
		<id>g7-release</id>
		<username>liufangwei</username>
		<password>xx</password>
	  </server>
	  <server>
		<id>g7-snapshots</id>
		<username>liufangwei</username>
		<password>xx</password>
	  </server>
```