快学Big Data --Maven(六)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xfg0218/article/details/82317032

Maven总结

 

概述

Mvn是开发人员比较常用的一个项目管理工具,主要是对项目的创建,编译,打包操作,命令简单使用。接下来简单总结一下常用的命令。

 

软件下载及配置

软件下载

mvn需要jdk的支持,jdk下载地址:

http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

 

 

官方下载地址:http://maven.apache.org/download.cgi

配置mvn

# yum install unzip

# unzip apache-maven-3.3.3.zip

 

在以下的配置文件中加入以下配置

# vi  /etc/profile

export JAVA_HOME=/opt/jdk1.8

export MVN_HOME=/opt/apache-maven-3.3.3

export PATH=$PATH:$JAVA_HOME/bin:$MVN_HOME/bin

 

查看mvn的版本

# mvn -v

Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T07:57:37-04:00)

Maven home: /opt/apache-maven-3.3.3

Java version: 1.8.0_131, vendor: Oracle Corporation

Java home: /opt/jdk1.8/jre

Default locale: en_US, platform encoding: UTF-8

OS name: "linux", version: "3.8.13-55.1.6.el7uek.x86_64", arch: "amd64", family: "unix"

 

mvn 常用地址

mvn库: http://repo2.maven.org/maven2/

 

常用jar下载地址: http://mvnrepository.com/

 

mvn 常用命令

查看mvn的帮助

# mvn -help

 

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 to 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

 

编译项目常用命令

生成项目结构

生成eclipse项目结构

# mvn  eclipse:eclipse

 

生成idea项目结构

# mvn  idea:idea

编译项目常用命令

编译源代码

# mvn compile

 

编译测试代码

# mvn test-compile

 

项目测试常用命令

运行测试代码

# mvn  test

 

 

项目打包命令

打包项目

#mvn  package

 

组合使用goal命令,如只打包不测试

# mvn  -Dtest  package

 

跳过测试进行打包

# mvn clean package -DskipTests -Prelease

Jar安装常用命令

在本地Repository中安装jar

# mvn  install

 

打成jar命令

# mvn  jar:jar

 

打包项目到本地仓库

# mvn clean install -DskipTests

 

打包项目跳过测试

# mvn clean package ****  -DskipTests -DskipRat

清除项目常用的命令

清除项目

#mvn  clean

查看错误的详细信息

查看错误的详细信息

# mvn  -e

 

发生jar的冲突显示冲突的原因

# mvn  install -x

 

 

强制更新命令

# mvn clean install -e -U

 

-e详细异常,-U强制更新

猜你喜欢

转载自blog.csdn.net/xfg0218/article/details/82317032