Maven常用指令官方解读

本文详细解释了Maven的生命周期阶段,包括compile、package、install和deploy等关键步骤的作用与区别。从源码编译到最终发布,每个阶段都有明确的任务与目标。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Maven使用时,对部分常用指令的区分不是很清楚,如compile  install   deploy的具体区别,故摘录其官方文档内容,并附注个人理解如下:

 

Maven Phases

·        validate: validate the project is correct and all necessaryinformation is available

·        从配置文件、目录结构等方面校验项目必要信息的正确性,不编译

·        compile: compile the source code of the project

·        编译源码,java--> class

·        test: test the compiled source code using a suitableunit testing framework. These tests should not require the code be packaged ordeployed

·        针对项目中使用unit test的测试套件执行测试,这里只有不依赖于发布的单元测试被执行

·        package: take the compiled code and package it in itsdistributable format, such as a JAR.

·        打包,将编译后的代码打包成发布格式,比如Jar,值得注意的是,这里只是将打包文件放到当前项目的target下,其他项目还无法引用

·        integration-test: process and deploy the package if necessary intoan environment where integration tests can be run

·        大概是打包后的测试,没用过

·        verify: run any checks to verify the package is valid andmeets quality criteria

·        包验证及质量测试,没用过,也不清楚如何定义验证需求和过程

·        install: install the package into the local repository,for use as a dependency in other projects locally

·        将打包后的包复制到本地仓库,这样其他项目就能正常引用了

·        deploy: done in an integration or release environment,copies the final package to the remote repository for sharing with otherdevelopers and projects.

·        install类似,发布最终版本到远端仓库,顾名思义:发布

·        clean: cleans up artifacts created by prior builds

·        site: generates site documentation for this project

 

源文档 <https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html>

 

 

总结下来:

·        compile是源码到字节码的编译;

·        package是打包到项目下;

·        install和deploy分别是发布到本地仓库和远端仓库。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值