grep -nr https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip vi .mvn/wrapper/maven-wrapper.properties
1 2 |
cd /home wget https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz --no-check-certificate |
1
|
tar -zxvf apache-maven-3.6.3-bin.tar.gz |
1
|
mv apache-maven-3.6.3 /opt/ |
vim /etc/profile
export MAVEN_HOME=/opt/apache-maven-3.6.3 export PATH=$MAVEN_HOME/bin:$PATH
1
|
source /etc/profile |
echo $MAVEN_HOME echo $PATH
1
|
mvn -v
|
vim /opt/apache-maven-3.6.3/conf/settings.xml
未配置时,默认地址是${user.home}/.m2/repository,以root用户登录,则本地仓路径为“/root/.m2/repository”。
<mirrors> <mirror> <id>huaweicloud</id> <mirrorOf>*</mirrorOf> <url>https://mirrors.huaweicloud.com/repository/maven/</url> </mirror> </mirrors> <profiles> <profile> <id>repoId1</id> <activation> <activeByDefault>true</activeByDefault> </activation> <repositories> <repository> <id>huaweimaven</id> <name>huaweimaven</name> <url>https://mirrors.huaweicloud.com/kunpeng/maven</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> </profile> </profiles>
对于通过代理访问外网的情况,需要配置网络代理(host、port、username、password根据实际环境修改)。
<proxies> <proxy> <id>my-proxy</id> <active>true</active> <protocol>https</protocol> <host>xxx</host> <port>xxx</port> <username>xxx</username> <password>xxx</password> <nonProxyHosts>local.net|some.host.com</nonProxyHosts> </proxy> <proxy> <id>my-proxy1</id> <active>true</active> <protocol>http</protocol> <host>xxx</host> <port>xxx</port> <username>xxx</username> <password>xxx</password> <nonProxyHosts>local.net|some.host.com</nonProxyHosts> </proxy> </proxies>