Maven命令的常用参数以及说明

Maven命令的常用参数以及说明

参数及说明查看命令

mvn -h
或者
mvn -help

使用以上命令可查看,maven常用参数以及说明,结果如下图:

C:\projectPackage>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 (disables output color)
 -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 (disables output color)
 -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,--toolchains <arg>                  Alternate path for the user
                                        toolchains file
 -T,--threads <arg>                     Thread count, for instance 2.0C
                                        where C is core multiplied
 -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,--version                           Display version information
 -V,--show-version                      Display version information
                                        WITHOUT stopping build
 -X,--debug                             Produce execution debug output

第一个 参数为缩减命令,后面为全称命令(也起到了缩写的解释作用),皆可使用。最后一列为该命令的作用的英文解释。

参数说明中文对照

以上是英文版,英语不错的可以推荐看一下,原汁原味,需要自己理解,毕竟英文的技术文档不是单词都认识就行的,哈哈,下面附上中文解释(该处引自Maven常用参数及其说明):

-h,--help                              Display help information
-am,--also-make                        构建指定模块,同时构建指定模块依赖的其他模块;
-amd,--also-make-dependents            构建指定模块,同时构建依赖于指定模块的其他模块;
-B,--batch-mode                        以批处理(batch)模式运行;
-C,--strict-checksums                  检查不通过,则构建失败;(严格检查)
-c,--lax-checksums                     检查不通过,则警告;(宽松检查)
-D,--define <arg>                      Define a system property
-e,--errors                            显示详细错误信息
-emp,--encrypt-master-password <arg>   Encrypt master security password
-ep,--encrypt-password <arg>           Encrypt server password
-f,--file <arg>                        使用指定的POM文件替换当前POM文件
-fae,--fail-at-end                     最后失败模式:Maven会在构建最后失败(停止)。如果Maven refactor中一个失败了,Maven会继续构建其它项目,并在构建最后报告失败。
-ff,--fail-fast                        最快失败模式: 多模块构建时,遇到第一个失败的构建时停止。
-fn,--fail-never                       从不失败模式:Maven从来不会为一个失败停止,也不会报告失败。
-gs,--global-settings <arg>            替换全局级别settings.xml文件(Alternate path for the global settings file)
-l,--log-file <arg>                    指定输出日志文件
-N,--non-recursive                     仅构建当前模块,而不构建子模块(即关闭Reactor功能)-nsu,--no-snapshot-updates             强制不更新SNAPSHOT(Suppress SNAPSHOT updates)
-U,--update-snapshots                  强制更新releases、snapshots类型的插件或依赖库(否则maven一天只会更新一次snapshot依赖)
-o,--offline                           运行offline模式,不联网进行依赖更新
-P,--activate-profiles <arg>           激活指定的profile文件列表(用逗号[,]隔开)
-pl,--projects <arg>                   手动选择需要构建的项目,项目间以逗号分隔;A project can be specified by [groupId]:artifactId or by its relative path.
-q,--quiet                             安静模式,只输出ERROR
-rf,--resume-from <arg>                从指定的项目(或模块)开始继续构建
-s,--settings <arg>                    替换用户级别settings.xml文件(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
-V,--show-version                      Display version information WITHOUT stopping build
-v,--version                           Display version information
-X,--debug                             输出详细信息,debug模式。
-cpu,--check-plugin-updates            【废弃】,仅为了向后兼容
-npr,--no-plugin-registry              【废弃】,仅为了向后兼容
-npu,--no-plugin-updates               【废弃】,仅为了向后兼容
-up,--update-plugins                   【废弃】,仅为了向后兼容

附:记录一下自己的项目生产的打包命令:mvn clean package -pl aipc-small-api -am -Pprd
解释一下就是先清除,再打包,选择指定需要构建的项目,并指定项目的groupId,除此之外,还需要构建所依赖的其他模块,最后选择prd环境进行构建

参考:
Maven常用参数及其说明

提高 Maven 编译速度可以采取以下几种方法: 1. 使用并行构建:Maven 3.2.1 版本及以上支持并行构建,可以通过在命令行中添加 `-T` 参数来指定并行线程数。例如,`mvn clean install -T 4` 表示使用 4 个线程进行构建。这样可以利用多核处理器的优势加快编译速度。 2. 配置增量编译:Maven 默认会对所有源代码进行重新编译,即使只有部分代码发生了变化。可以通过配置增量编译插件来只编译发生变化的代码。常用的插件有 `maven-compiler-plugin` 和 `maven-jar-plugin`。 3. 使用本地仓库:Maven 默认会从远程仓库下载依赖的 JAR 包,这会消耗一定的时间。可以将常用的依赖手动安装到本地仓库,这样在编译时就不需要从远程仓库下载了。可以使用 `mvn install:install-file` 命令将 JAR 包安装到本地仓库。 4. 配置镜像仓库:可以配置使用国内的镜像仓库,这样可以加快下载依赖的速度。可以在 Maven 的配置文件 `settings.xml` 中配置 `<mirrors>` 标签来指定镜像仓库。 5. 使用缓存:可以使用插件来缓存已编译的类文件,避免重复编译。常用的插件有 `maven-compiler-plugin` 的 `useIncrementalCompilation` 参数和 `maven-clean-plugin` 的 `excludeDefaultDirectories` 参数。 6. 调整内存设置:可以通过调整 Maven 的内存设置来提高编译速度。可以在 Maven 的配置文件 `settings.xml` 中配置 `<build>` 标签下的 `<memory>` 标签来指定内存设置。 7. 使用构建缓存工具:可以使用构建缓存工具,如 Gradle 或 Bazel,来代替 Maven。这些工具具有更高效的构建机制,可以显著提高编译速度。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值