加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > CentOS > 正文

CentOS 上安装Maven

发布时间:2020-05-22 11:36:45 所属栏目:CentOS 来源:互联网
导读:采用如下步骤,在CentOS上安装Maven。 (一) 下载MAVEN安装包 访问MAVEN网站,下载Maven安装包 (二) 解压并做一个软链接 将下载后的tar.gz上传到服务器上,并使用tar命令解压 [root@dev18 srv]# tar -zvxf apache-maven-3.3.9-bin.tar.gz 执行ln -s命令创建一

采用如下步骤,在CentOS上安装Maven。

(一) 下载MAVEN安装包

访问MAVEN网站,下载Maven安装包

(二) 解压并做一个软链接

将下载后的tar.gz上传到服务器上,并使用tar命令解压

[root@dev18 srv]# tar -zvxf apache-maven-3.3.9-bin.tar.gz

执行ln -s命令创建一个链接。

[root@dev18 srv]# ln -s apache-maven-3.3.9  apache-maven

执行ll命令查看一下:

lrwxrwxrwx 1 root root        18 Dec 22 13:33 apache-maven -> apache-maven-3.3.9
drwxr-xr-x 6 root root      4096 Dec 22 13:33 apache-maven-3.3.9

(三) 配置Maven环境变量

使用 vi /etc/profile命令,

[root@dev18 ~]# vi /etc/profile

添加如下内容:

export  M2_HOME=/srv/apache-maven
export  PATH=$PATH:$JAVA_HOME/bin:$M2_HOME/bin

(四) 执行source使环境变量生效

使用 source /etc/profile 让新添加的环境变量生效。

[root@dev18 ~]# source /etc/profile

(五) 查看是否安装成功

最后我们可以使用 mvn -v 命令来看一下Maven是否安装成功。

[root@dev18 ~]# mvn -v
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00)
Maven home: /srv/apache-maven
Java version: 1.7.0_71,vendor: Oracle Corporation
Java home: /usr/java/jdk1.7.0_71/jre
Default locale: en_US,platform encoding: UTF-8
OS name: "linux",version: "2.6.32-573.el6.x86_64",arch: "amd64",family: "unix"

或者其它 Maven 命令如 mvn -h查看安装后Maven的信息:

[root@dev18 ~]# mvn -h

usage: mvn [options] [<goal(s)>] [<phase(s)>]

Options:
 -am,--also-make                        If project list is specified,also
                                        build projects required by the
                                        list
 -amd,--also-make-dependents            If project list is specified,also
                                        build projects that depend on
                                        projects on the list
 -B,--batch-mode                        Run in non-interactive (batch)
                                        mode
 -b,--builder <arg>                     The id of the build strategy to
                                        use.
 -C,--strict-checksums                  Fail the build if checksums don't
                                        match
 -c,--lax-checksums                     Warn if checksums don't match
 -cpu,--check-plugin-updates            Ineffective,only kept for
                                        backward compatibility
 -D,--define <arg>                      Define a system property
 -e,--errors                            Produce execution error messages
 -emp,--encrypt-master-password <arg>   Encrypt master security password
 -ep,--encrypt-password <arg>           Encrypt server password
 -f,--file <arg>                        Force the use of an alternate POM
                                        file (or directory with pom.xml).
 -fae,--fail-at-end                     Only fail the build afterwards;
                                        allow all non-impacted builds to
                                        continue
 -ff,--fail-fast                        Stop at first failure in
                                        reactorized builds
 -fn,--fail-never                       NEVER fail the build,regardless
                                        of project result
 -gs,--global-settings <arg>            Alternate path for the global
                                        settings file
 -gt,--global-toolchains <arg>          Alternate path for the global
                                        toolchains file
 -h,--help                              Display help information
 -l,--log-file <arg>                    Log file where all build output
                                        will go.
 -llr,--legacy-local-repository         Use Maven 2 Legacy Local
                                        Repository behaviour,ie no use of
                                        _remote.repositories. Can also be
                                        activated by using
                                        -Dmaven.legacyLocalRepo=true
 -N,--non-recursive                     Do not recurse into sub-projects
 -npr,--no-plugin-registry              Ineffective,only kept for
                                        backward compatibility
 -npu,--no-plugin-updates               Ineffective,only kept for
                                        backward compatibility
 -nsu,--no-snapshot-updates             Suppress SNAPSHOT updates
 -o,--offline                           Work offline
 -P,--activate-profiles <arg>           Comma-delimited list of profiles
                                        to activate
 -pl,--projects <arg>                   Comma-delimited list of specified
                                        reactor projects to build instead
                                        of all projects. A project can be
                                        specified by [groupId]:artifactId
                                        or by its relative path.
 -q,--quiet                             Quiet output - only show errors
 -rf,--resume-from <arg>                Resume reactor from specified
                                        project
 -s,--settings <arg>                    Alternate path for the user
                                        settings file
 -T,--threads <arg>                     Thread count,for instance 2.0C
                                        where C is core multiplied
 -t,--toolchains <arg>                  Alternate path for the user
                                        toolchains file
 -U,--update-snapshots                  Forces a check for missing
                                        releases and updated snapshots on
                                        remote repositories
 -up,--update-plugins                   Ineffective,only kept for
                                        backward compatibility
 -V,--show-version                      Display version information
                                        WITHOUT stopping build
 -v,--version                           Display version information
 -X,--debug                             Produce execution debug output

至此,Maven安装成功~~。

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读