maven 安装和配置
linux下安装
环境: ubuntu1.8 jdk1.8
下载:
进入http://www-eu.apache.org/dist/maven/maven-3/下载
apache-maven-3.6.0-bin.tar.gz 版本
安装:
tar -xzvf apache-maven-3.6.0-bin.tar.gz #解压
配置环境变量
export JAVA_HOME=/usr/local/jdk1.8.0 export JRE_HOME=$JAVA_HOME/jre export MYSQL_HOME=/usr/local/mysql export ECLIPSE_HOME=/usr/local/eclipse export MAVEN_HOME=/usr/local/maven export PATH=$JAVA_HOME/usr/local/eclipse:$ECLIPSE_HOME:$MAVEN_HOME/bin:$PATH: export PATH=/snap/bin:$PATH export PATH=$PATH:/usr/local/mysql/bin: export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH export CLASSPATH=.:/home/share:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$MYSQL_HOME/lib:$MYSQL_HOME/bin:ECLIPSE_HOME:MAVEN_HOME/lib: export CLASSPATH=.:/snap/bin
windows下安装
和linux下一样
配置
设置maven的本地仓库路径
1 打开D:\maven\apache-maven-3.6.1\conf路径中的settings.xml
2 修改localRepository选项,路径设置为你自定义的路径,保存如下
<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 | The path to the local repository maven will use to store artifacts. | | Default: ${user.home}/.m2/repository --> <localRepository>E:/maven/repository</localRepository>
配置仓库地址
在setting.xml 的<mirrors></mirrors>节点新增<mirror></mirror>
<!--阿里云仓库--> <mirror> <id>nexus-aliyun</id> <name>Nexus aliyun</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror>