前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >mvn常用命令

mvn常用命令

作者头像
小徐
发布2019-08-05 14:45:50
1.5K0
发布2019-08-05 14:45:50
举报
文章被收录于专栏:Greenplum

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

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2018-06-02,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 河马coding 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Maven总结
    • 概述
      • 软件下载及配置
        • 软件下载
        • 配置mvn
      • mvn 常用地址
        • mvn 常用命令
          • 查看mvn的帮助
          • 编译项目常用命令
      相关产品与服务
      项目管理
      CODING 项目管理(CODING Project Management,CODING-PM)工具包含迭代管理、需求管理、任务管理、缺陷管理、文件/wiki 等功能,适用于研发团队进行项目管理或敏捷开发实践。结合敏捷研发理念,帮助您对产品进行迭代规划,让每个迭代中的需求、任务、缺陷无障碍沟通流转, 让项目开发过程风险可控,达到可持续性快速迭代。
      领券
      问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档