如果希望本地maven项目从私服上拉取依赖,可以在maven的setting.xml中添加下面的配置:
</profiles>
<profile>
<id>dev</id>
<repositories>
<repository>
<id>你的私服id</id>
<url>你的私服地址</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>public</id>
<name>Public Repositories</name>
<url>你的私服地址</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>你的私服id</id>
<url>地址</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
</pluginRepository>
<pluginRepository>
<id>public</id>
<name>Public Repositories</name>
<url>你的私服地址</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>dev</activeProfile>
</activeProfiles>
添加账号密码:
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
| This is the configuration file for Maven. It can be specified at two levels:
|
| 1. User Level. This settings.xml file provides configuration for a single user,
| and is normally provided in ${user.home}/.m2/settings.xml.
|
| NOTE: This location can be overridden with the CLI option:
|
| -s /path/to/user/settings.xml
|
| 2. Global Level. This settings.xml file provides configuration for all Maven
| users on a machine (assuming they're all using the same Maven
| installation). It's normally provided in
| ${maven.conf}/settings.xml.
|
| NOTE: This location can be overridden with the CLI option:
|
| -gs /path/to/global/settings.xml
|
| The sections in this sample file are intended to give you a running start at
| getting the most out of your Maven installation. Where appropriate, the default
| values (values used when the setting is not specified) are provided.
|
|-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>D:\repo</localRepository>
<servers>
<server>
<id>mvn-repo</id>
<username>zs</username>
<password>******</password>
</server>
<server>
<id>mvn-snapshots</id>
<username>zs</username>
<password>******</password>
</server>
<server>
<id>mvn-releases</id>
<username>zs</username>
<password>******</password>
</server>
<server>
<id>mvn-mirror</id>
<username>zs</username>
<password>******</password>
</server>
</servers>
<mirrors>
<mirror>
<id>mvn-mirror</id>
<mirrorOf>centra</mirrorOf>
<name>mvn-mirror</name>
<url>https://depend.xxx.com/artifactory/mvn-repo/</url>
</mirror>
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>mvn-repo</id>
<repositories>
<repository>
<id>mvn-repo</id>
<url>https://depend.xxx.com/artifactory/mvn-repo/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<!-- If you want to get depedencies from external servers, remove the annotation! -->
<activeProfiles>
<activeProfile>mvn-repo</activeProfile>
</activeProfiles>
</settings>