Files
tldr/pages.zh/common/mvn.md
2021-10-01 15:28:01 -03:00

38 lines
951 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# mvn
> Apache Maven.
> 用于构建和管理基于 Java 的项目的工具。
> 更多信息:<https://maven.apache.org>.
- 编译项目:
`mvn compile`
- 将编译后的代码打包成可分发格式,比如 `jar`
`mvn package`
- 编译和打包,跳过单元测试:
`mvn package -DskipTests`
- 在本地 maven 存储库中安装构建的包(这也会调用 compile 和 package 命令):
`mvn install`
- 从目标目录中删除构建工件,通常用来清理之前的编译结果:
`mvn clean`
- 执行清理操作,然后进行编译打包:
`mvn clean package`
- 执行清理操作并使用给定的构建配置打包代码,比如 `profileId` 如果有 dev、test、pro可以指定其中一个 `profileId` 用来选择具体执行环境:
`mvn clean -P{{profileId}} package`
- 使用 main 方法运行一个类:
`mvn exec:java -Dexec.mainClass="{{com.example.Main}}" -Dexec.args="{{参数1 参数2}}"`