Devops(一):CentOS7 安装Maven3.6.1详解
https://yq.aliyun.com/topic/78?spm=5176.8290451.656547.7.rMYhAF
https://yq.aliyun.com/activity/155?utm_campaign=155&utm_medium=images&utm_source=cnblogs&utm_content=m_11258#guid-656547
Maven用来做什么?
Maven是一个项目管理工具,它包含了一个项目对象模型 (Project Object Model),一组标准集合,一个项目生命周期(Project Lifecycle),一个依赖管理系统(Dependency Management System),和用来运行定义在生命周期阶段(phase)中插件(plugin)目标(goal)的逻辑。当你使用Maven的时候,你用一个明确定义的项目对象模型来描述你的项目,然后Maven可以应用横切的逻辑,这些逻辑来自一组共享的(或者自定义的)插件。
Maven 有一个生命周期,当你运行 mvn install 的时候被调用。这条命令告诉 Maven 执行一系列的有序的步骤,直到到达你指定的生命周期。遍历生命周期旅途中的一个影响就是,Maven 运行了许多默认的插件目标,这些目标完成了像编译和创建一个 JAR 文件这样的工作。
此外,Maven能够很方便的帮你管理项目报告,生成站点,管理JAR文件,等等。
Maven安装
安装环境为 centos7,jdk1.8
1)从Maven官网下载Maven安装包
官网下载maven地址:http://maven.apache.org/download.cgi
复制的apache-maven-3.6.1.tar.gz的下载地址为:http://mirror.bit.edu.cn/apache/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz
在centos7系统中使用root账户执行wget来下载maven 3.6.1安装包:
[root@master ~]# mkdir -p /opt/devopt/maven
[root@master ~]# cd /opt/devopt/maven
[root@master maven]# wget http://mirror.bit.edu.cn/apache/maven/maven-3/3.6.1/source/apache-maven-3.6.1-bin.tar.gz
--2019-08-21 22:41:00-- http://mirror.bit.edu.cn/apache/maven/maven-3/3.6.1/source/apache-maven-3.6.1-bin.tar.gz
Resolving mirror.bit.edu.cn (mirror.bit.edu.cn)... 114.247.56.117, 2001:da8:204:1::22
Connecting to mirror.bit.edu.cn (mirror.bit.edu.cn)|114.247.56.117|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2019-08-21 22:41:03 ERROR 404: Not Found.
[root@master maven]# wget http://mirror.bit.edu.cn/apache/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz
--2019-08-21 22:42:07-- http://mirror.bit.edu.cn/apache/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz
Resolving mirror.bit.edu.cn (mirror.bit.edu.cn)... 114.247.56.117, 2001:da8:204:1::22
Connecting to mirror.bit.edu.cn (mirror.bit.edu.cn)|114.247.56.117|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9136463 (8.7M) [application/octet-stream]
Saving to: ‘apache-maven-3.6.1-bin.tar.gz’
100%[=================================================================================================================================================================>] 9,136,463 54.3KB/s in 5m 23s
2019-08-21 22:47:30 (27.6 KB/s) - ‘apache-maven-3.6.1-bin.tar.gz’ saved [9136463/9136463]
[root@master maven]# ls
apache-maven-3.6.1-bin.tar.gz
2)解压下载的maven文件进行安装
[root@master maven]# ls
apache-maven-3.6.1-bin.tar.gz
[root@master maven]# tar -zxvf apache-maven-3.6.1-bin.tar.gz
apache-maven-3.6.1/README.txt
apache-maven-3.6.1/LICENSE
apache-maven-3.6.1/NOTICE
apache-maven-3.6.1/lib/
apache-maven-3.6.1/lib/slf4j-api.license
apache-maven-3.6.1/lib/checker-compat-qual.license
apache-maven-3.6.1/lib/jsr250-api.license
apache-maven-3.6.1/lib/jcl-over-slf4j.license
apache-maven-3.6.1/lib/org.eclipse.sisu.plexus.license
apache-maven-3.6.1/lib/animal-sniffer-annotations.license
apache-maven-3.6.1/lib/org.eclipse.sisu.inject.license
apache-maven-3.6.1/lib/jansi-native/
apache-maven-3.6.1/lib/jansi-native/freebsd64/
apache-maven-3.6.1/lib/jansi-native/osx/
apache-maven-3.6.1/lib/jansi-native/windows32/
apache-maven-3.6.1/lib/jansi-native/linux32/
apache-maven-3.6.1/lib/jansi-native/freebsd32/
apache-maven-3.6.1/lib/jansi-native/windows64/
apache-maven-3.6.1/lib/jansi-native/linux64/
apache-maven-3.6.1/lib/jansi-native/freebsd64/libjansi.so
apache-maven-3.6.1/lib/jansi-native/osx/libjansi.jnilib
apache-maven-3.6.1/lib/jansi-native/windows32/jansi.dll
apache-maven-3.6.1/lib/jansi-native/linux32/libjansi.so
apache-maven-3.6.1/lib/jansi-native/freebsd32/libjansi.so
apache-maven-3.6.1/lib/jansi-native/windows64/jansi.dll
apache-maven-3.6.1/lib/jansi-native/linux64/libjansi.so
apache-maven-3.6.1/bin/mvn.cmd
apache-maven-3.6.1/bin/m2.conf
apache-maven-3.6.1/bin/mvnDebug.cmd
apache-maven-3.6.1/bin/mvnDebug
apache-maven-3.6.1/bin/mvn
apache-maven-3.6.1/bin/mvnyjp
apache-maven-3.6.1/conf/
apache-maven-3.6.1/conf/logging/
apache-maven-3.6.1/conf/settings.xml
apache-maven-3.6.1/conf/toolchains.xml
apache-maven-3.6.1/conf/logging/simplelogger.properties
apache-maven-3.6.1/lib/ext/
apache-maven-3.6.1/lib/jansi-native/
apache-maven-3.6.1/lib/ext/README.txt
apache-maven-3.6.1/lib/jansi-native/README.txt
apache-maven-3.6.1/boot/plexus-classworlds-2.6.0.jar
apache-maven-3.6.1/lib/maven-embedder-3.6.1.jar
apache-maven-3.6.1/lib/maven-settings-3.6.1.jar
apache-maven-3.6.1/lib/plexus-utils-3.2.0.jar
apache-maven-3.6.1/lib/maven-settings-builder-3.6.1.jar
apache-maven-3.6.1/lib/maven-builder-support-3.6.1.jar
apache-maven-3.6.1/lib/plexus-interpolation-1.25.jar
apache-maven-3.6.1/lib/plexus-component-annotations-1.7.1.jar
apache-maven-3.6.1/lib/plexus-sec-dispatcher-1.4.jar
apache-maven-3.6.1/lib/plexus-cipher-1.7.jar
apache-maven-3.6.1/lib/maven-core-3.6.1.jar
apache-maven-3.6.1/lib/maven-model-3.6.1.jar
apache-maven-3.6.1/lib/maven-repository-metadata-3.6.1.jar
apache-maven-3.6.1/lib/maven-artifact-3.6.1.jar
apache-maven-3.6.1/lib/commons-lang3-3.8.1.jar
apache-maven-3.6.1/lib/maven-plugin-api-3.6.1.jar
apache-maven-3.6.1/lib/org.eclipse.sisu.plexus-0.3.3.jar
apache-maven-3.6.1/lib/cdi-api-1.0.jar
apache-maven-3.6.1/lib/jsr250-api-1.0.jar
apache-maven-3.6.1/lib/javax.inject-1.jar
apache-maven-3.6.1/lib/org.eclipse.sisu.inject-0.3.3.jar
apache-maven-3.6.1/lib/maven-model-builder-3.6.1.jar
apache-maven-3.6.1/lib/maven-resolver-provider-3.6.1.jar
apache-maven-3.6.1/lib/maven-resolver-api-1.3.3.jar
apache-maven-3.6.1/lib/maven-resolver-spi-1.3.3.jar
apache-maven-3.6.1/lib/maven-resolver-util-1.3.3.jar
apache-maven-3.6.1/lib/maven-resolver-impl-1.3.3.jar
apache-maven-3.6.1/lib/slf4j-api-1.7.25.jar
apache-maven-3.6.1/lib/maven-shared-utils-3.2.1.jar
apache-maven-3.6.1/lib/commons-io-2.5.jar
apache-maven-3.6.1/lib/guice-4.2.1-no_aop.jar
apache-maven-3.6.1/lib/aopalliance-1.0.jar
apache-maven-3.6.1/lib/guava-25.1-android.jar
apache-maven-3.6.1/lib/jsr305-3.0.2.jar
apache-maven-3.6.1/lib/checker-compat-qual-2.0.0.jar
apache-maven-3.6.1/lib/error_prone_annotations-2.1.3.jar
apache-maven-3.6.1/lib/j2objc-annotations-1.1.jar
apache-maven-3.6.1/lib/animal-sniffer-annotations-1.14.jar
apache-maven-3.6.1/lib/commons-cli-1.4.jar
apache-maven-3.6.1/lib/maven-compat-3.6.1.jar
apache-maven-3.6.1/lib/wagon-provider-api-3.3.2.jar
apache-maven-3.6.1/lib/wagon-http-3.3.2-shaded.jar
apache-maven-3.6.1/lib/jcl-over-slf4j-1.7.25.jar
apache-maven-3.6.1/lib/wagon-file-3.3.2.jar
apache-maven-3.6.1/lib/maven-resolver-connector-basic-1.3.3.jar
apache-maven-3.6.1/lib/maven-resolver-transport-wagon-1.3.3.jar
apache-maven-3.6.1/lib/maven-slf4j-provider-3.6.1.jar
apache-maven-3.6.1/lib/jansi-1.17.1.jar
[root@master maven]# ls
apache-maven-3.6.1 apache-maven-3.6.1-bin.tar.gz
[root@master maven]# cd apache-maven-3.6.1
[root@master apache-maven-3.6.1]# ls
bin boot conf lib LICENSE NOTICE README.txt
[root@master apache-maven-3.6.1]# cd conf/
[root@master conf]# ls
logging settings.xml toolchains.xml
[root@master conf]#
3)添加Maven_Home环境变量,并验证
1)vim /etc/profile
在/etc/profile最后追加Maven_Home,并追加到Path中:
[root@master apache-maven-3.6.1]# vim /etc/profile 。。。 export WORK_SPACE=/opt/ export JAVA_HOME=$WORK_SPACE/jdk1.8.0_171 export JRE_HOME=/opt/jdk1.8.0_171/jre export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH export CLASSPATH=$CLASSPATH:.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib export SCALA_HOME=$WORK_SPACE/scala-2.11.0 export PATH=$PATH:$SCALA_HOME/bin export MAVEN_HOME=/opt/devops/maven/apache-maven-3.6.1 export PATH=$PATH:$MAVEN_HOME/bin "/etc/profile" 98L, 2475C written [root@master apache-maven-3.6.1]#
2)运行source /etc/profile使其生效
[root@master apache-maven-3.6.1]# source /etc/profile [root@master apache-maven-3.6.1]#
3)运行mvn -version验证生效
[root@master conf]# mvn -v
Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-05T03:00:29+08:00)
Maven home: /opt/devops/maven/apache-maven-3.6.1
Java version: 1.8.0_171, vendor: Oracle Corporation, runtime: /opt/jdk1.8.0_171/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-862.el7.x86_64", arch: "amd64", family: "unix"
[root@master conf]# cd ~
[root@master ~]# mvn -v
Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-05T03:00:29+08:00)
Maven home: /opt/devops/maven/apache-maven-3.6.1
Java version: 1.8.0_171, vendor: Oracle Corporation, runtime: /opt/jdk1.8.0_171/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-862.el7.x86_64", arch: "amd64", family: "unix"
[root@master ~]#
配置远程中央仓库:
一般情况下可以配置为国外的远程中央仓库,但是在国内从国外远程中央仓库下载jar包的速度比较差。如果国内的话,建议使用阿里的远程中央仓库(下载速度快)。
vi /opt/devops/maven/apache-maven-3.6.1/conf/settings.xml
在mirrors标签下添加:
<mirror> <id>alimaven</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror>
配置后效果:
基础才是编程人员应该深入研究的问题,比如:
1)List/Set/Map内部组成原理|区别
2)mysql索引存储结构&如何调优/b-tree特点、计算复杂度及影响复杂度的因素。。。
3)JVM运行组成与原理及调优
4)Java类加载器运行原理
5)Java中GC过程原理|使用的回收算法原理
6)Redis中hash一致性实现及与hash其他区别
7)Java多线程、线程池开发、管理Lock与Synchroined区别
8)Spring IOC/AOP 原理;加载过程的。。。
【+加关注】。