1.下载和配置环境变量
官网下载,解压,配置环境变量
2.配置settings.xml
找到解压目录下conf文件夹下的settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--
| 有两个级别的配置文件
| 1. 用户配置文件:${user.home}/.m2/settings.xml.
| 2. 全局配置文件:${maven.conf}/settings.xml.
|-->
<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
| 本地仓库位置:
| 默认值为:${user.home}/.m2/repository
-->
<!-- 配置本地仓库位置 -->
<localRepository>F:/Develop/Apache/Maven/LocalRepository</localRepository>
<!-- interactiveMode
| 是否需要通过用户输入设置某些值,如果为false则使用默认值
| 默认值为: true
<interactiveMode>true</interactiveMode>
-->
<!-- offline
| 是否使用离线模式
| 默认值位置: false
<offline>false</offline>
-->
<!-- pluginGroups
| 设置插件组的标识
|-->
<pluginGroups>
<!--
<pluginGroup>com.your.plugins</pluginGroup>
-->
</pluginGroups>
<!-- proxies
| 设置网络代理
|-->
<proxies>
<!-- proxy
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username>proxyuser</username>
<password>proxypass</password>
<host>proxy.host.net</host>
<port>80</port>
<nonProxyHosts>local.net|some.host.com</nonProxyHosts>
</proxy>
-->
</proxies>
<!-- servers
| 配置服务器
|-->
<servers>
<!-- server
<server>
<id>deploymentRepo</id>
<username>repouser</username>
<password>repopwd</password>
</server>
-->
<!--
<server>
<id>siteServer</id>
<privateKey>/path/to/private/key</privateKey>
<passphrase>optional; leave empty if not used.</passphrase>
</server>
-->
</servers>
<!-- mirrors
| 配置镜像服务器
|-->
<mirrors>
<!-- mirror
| mirrorOf 用于设置要从该镜像进行下载的仓库名 *代表所有仓库
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->
<!-- 配置阿里云镜像仓库 -->
<mirror>
<id>aliyunmaven</id>
<mirrorOf>*</mirrorOf>
<name>阿里云公共仓库</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
</mirrors>
<!-- profiles
| maven项目的配置
|-->
<profiles>
<!-- profile
<profile>
<id>jdk-1.4</id>
<activation>
<jdk>1.4</jdk>
</activation>
<repositories>
<repository>
<id>jdk14</id>
<name>Repository for JDK 1.4 builds</name>
<url>http://www.myhost.com/maven/jdk14</url>
<layout>default</layout>
<snapshotPolicy>always</snapshotPolicy>
</repository>
</repositories>
</profile>
-->
<!--
| <plugin>
| <groupId>org.myco.myplugins</groupId>
| <artifactId>myplugin</artifactId>
|
| <configuration>
| <tomcatLocation>${tomcatPath}</tomcatLocation>
| </configuration>
| </plugin>
<profile>
<id>env-dev</id>
<activation>
<property>
<name>target-env</name>
<value>dev</value>
</property>
</activation>
<properties>
<tomcatPath>/path/to/tomcat/instance</tomcatPath>
</properties>
</profile>
-->
</profiles>
<!-- activeProfiles
| 所有maven项目都使用的配置
<activeProfiles>
<activeProfile>alwaysActiveProfile</activeProfile>
<activeProfile>anotherAlwaysActiveProfile</activeProfile>
</activeProfiles>
-->
</settings>
3.手动安装jar包(当中央仓库没有该jar包时)
mvn install:install-file -Dfile=jar文件所在路径 -DgroupId=包名 -DartifactId=项目名 -Dversion=版本号
-Dfile:为本地 jar 包的位置
-DgroupId:打到 Maven 仓库对应 pom 文件中引用的 groupId
-DartifactId:打到 Maven 仓库对应 pom 文件中引用的 artifactId
-Dversion:版本号