Maven安装
- https://maven.apache.org/访问Maven网站
- 下载相对应的二进制包
- 配置环境变量
下载之后,解压:
tar -zxvf apache-maven-3.6.3-bin.tar.gz -C /usr/local
配置文件:
export MAVEN_HOME=/usr/local/maven
export PATH=$PATH:$MAVEN_HOME/bin
测试:
settings.xml配置
一般这个的配置文件用来配置相应的仓库地址,有的可以用URL进行访问,有的就不行。
大多数用到阿里云的仓库和中心仓库如下:
一定要会自己找仓库的域名,而不是从复制粘贴,否则会出现很多问题,因为有的仓库地址会变换,比如说现在很多域名都用https了,用http就连接不到仓库了(本人就出现过这样的问题)
<?xml version="1.0" encoding="UTF-8"?>
<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>/home/${username}/.m2/repository</localRepository>
<mirrors>
<!-- 阿里云仓库 -->
<mirror>
<id>aliyunmaven</id>
<mirrorOf>*</mirrorOf>
<name>阿里云公共仓库</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
</mirrors>
<!-- jdk环境配置-->>
<profiles>
<profile>
<id>jdk-1.8</id>
<activation>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
</profiles>
</settings>
中央仓库如下:
<?xml version="1.0" encoding="UTF-8"?>
<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>/home/${username}/.m2/repository</localRepository>
<mirrors>
<!-- 阿里云仓库 -->
<mirror>
<id>mirrorId</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
</mirror>
</mirrors>
<!-- jdk环境配置-->>
<profiles>
<profile>
<id>jdk-1.8</id>
<activation>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
</profiles>
</settings>