maven centos7
maven centos7
maven centos7

maven Binary方式安装使用

安装maven之前区别系统中安装了 JDK,

1
2
下载 maven 
http://39.137.67.79/mirror.bit.edu.cn/apache/maven/maven-3/3.6.0/binaries/apache-maven-3.6.0-bin.tar.gz

解压

1
tar -zxvf apache-maven-3.6.0-bin.tar.gz -C /data/server/

修改环境变量

1
2
3
4
5
vim /etc/profile

#set maven
export M2_HOME=/data/server/apache-maven-3.6.0
export PATH=$PATH:$M2_HOME/bin

验证

1
2
source /etc/profile    #使环境变量生效
mvn -v

root passwd

maven source 方式安装使用

maven 仓库位置

maven默认仓库位置C:/Users/Administrator/.m2/repository,如果改为自己指定本地位置位置,可通过修改maven安装包下面配置文件…\apache-maven-3.6.0\conf\settings.xml`中55行左右

1
<localRepository>D:\soft_position\java\maven_repo</localRepository>

修改完成后可以执行命令mvn help:system后,到新的仓库位置看一下是否有下载的包

设置aliyun仓库

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<mirrors>
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
</mirrors>

<profiles>
<profile>
<id>jdk-1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<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>