Ubuntu20.04安装 maven并配置阿里源
-
sudo apt update
-
sudo apt install maven #安装maven,默认安装路径为/usr/share/maven
-
添加maven环境配置,在/etc/profile.d文件夹下新建配置文件maven.sh
vim /etc/profile.d/maven.sh
maven.sh内容如下:
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 export M2_HOME=/usr/share/maven export MAVEN_HOME=/usr/share/maven export PATH=${M2_HOME}/bin:${PATH}
-
加载环境配置
source /etc/profile.d/maven.sh
-
maven本地仓库初始化,在用户家目录下会生成一个.m2的文件夹
sudo mvn help:system
-
拷贝setting.xml到.m2文件夹下
cd ~/.m2 cp ${MAVEN_HOME}/conf/settings.xml .
-
修改settings.xml文件,配置阿里源
sudo vim settings.xml
<mirror> <id>alimaven</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror>
-
测试
mvn -v