mvn compile
compile编译命令将src/main/java和src/main/resources中的代码和配置文件编译到target/classes中,不会对src/test/java中的测试类进行编译
MVN编译使用
maven-resources-plugin:2.6:resources
maven-compiler-plugin:2.5.1:compile
mvn test
test命令首先将src/test/java中的测试代码编译到target/test-classes中,然后执行target/test-classes中的单元测试类,将单元测试的执行结果文件保存到target/surefire-reports目录中,这些文件是junit帮助生成的,详细记录了单元测试的类,方法以及单元测试失败的异常信息
mvn测试命令使用
maven-resources-plugin:2.6:testResources
maven-compiler-plugin:2.5.1:compile
maven-surefire-plugin:2.12.4:test
mvn clean
mvn compile采取增量编译的方式,如果classes目录下已经编译过某个类或者单元测试类,而此时这些类没有变化,那么mvn compile不会重新编译这些类,那么如果让这些类重新编译,需要将target/classes,target/test-classes目录下的类清除,这就是mvn clean的工作。它使用maven-clean-plugin:2.5 clean执行clean操作,操作结果如下:
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ LearnMaven --- [INFO] Deleting /home/tom/development/learnmaven/maven-ch01/target [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 3.837 s [INFO] Finished at: 2014-08-02T08:22:40+08:00 [INFO] Final Memory: 9M/108M [INFO] -----------------------------------------------------------------------
mvn package
mvn package包含了编译的步骤,它是将
1. 将src/main/java中的代码编译到target/classes路径下
2. 将src/main/resources中的资源文件编译到target/classes路径下
3. 将src/test/java中的代码编译到target/test-classes路径下
4. 将src/test/resources中的资源文件编译到target/test-classes路径下
5. 默认打包成jar,包中不包含测试类的输出,输出信息如下
hadoop-os:~/development/learnmaven/maven-ch01$ mvn package [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building LearnMaven 1.0 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ LearnMaven --- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ LearnMaven --- [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! [INFO] Compiling 1 source file to /home/tom/development/learnmaven/maven-ch01/target/classes [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ LearnMaven --- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory /home/tom/development/learnmaven/maven-ch01/src/test/resources [INFO] [INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ LearnMaven --- [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! [INFO] Compiling 1 source file to /home/tom/development/learnmaven/maven-ch01/target/test-classes [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ LearnMaven --- [INFO] Surefire report directory: /home/tom/development/learnmaven/maven-ch01/target/surefire-reports ------------------------------------------------------- T E S T S ------------------------------------------------------- Running com.tom.HelloMavenTest Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.109 sec Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
mvn install
将Maven模块添加到本地仓库中,
hadoop-os:~/development/learnmaven/maven-ch01$ mvn install [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building LearnMaven-ch01 1.0 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ LearnMaven-ch01 --- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ LearnMaven-ch01 --- [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! [INFO] Compiling 1 source file to /home/tom/development/learnmaven/maven-ch01/target/classes [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ LearnMaven-ch01 --- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory /home/tom/development/learnmaven/maven-ch01/src/test/resources [INFO] [INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ LearnMaven-ch01 --- [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! [INFO] Compiling 1 source file to /home/tom/development/learnmaven/maven-ch01/target/test-classes [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ LearnMaven-ch01 --- [INFO] Surefire report directory: /home/tom/development/learnmaven/maven-ch01/target/surefire-reports ------------------------------------------------------- T E S T S ------------------------------------------------------- Running com.tom.HelloMavenTest Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.106 sec Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO] [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ LearnMaven-ch01 --- [INFO] Building jar: /home/tom/development/learnmaven/maven-ch01/target/LearnMaven-ch01-1.0.jar [INFO] [INFO] --- maven-install-plugin:2.4:install (default-install) @ LearnMaven-ch01 --- [INFO] Installing /home/to/mdevelopment/learnmaven/maven-ch01/target/LearnMaven-ch01-1.0.jar to /home/tom/.m2/repository/LearnMaven/LearnMaven-ch01/1.0/LearnMaven-ch01-1.0.jar [INFO] Installing /home/tom/development/learnmaven/maven-ch01/pom.xml to /home/tom/.m2/repository/LearnMaven/LearnMaven-ch01/1.0/LearnMaven-ch01-1.0.pom [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 4.464 s [INFO] Finished at: 2014-08-02T09:26:51+08:00 [INFO] Final Memory: 15M/169M [INFO] ------------------------------------------------------------------------
相关推荐
maven学习笔记maven学习笔记maven学习笔记
**Maven学习笔记** 在Java开发领域,Maven是一个不可或缺的构建工具,它极大地简化了项目的构建、管理和依赖管理过程。Maven通过使用一个项目对象模型(Project Object Model,POM),XML格式的配置文件,定义了...
** Maven基础入门 ** Maven是一个Java项目管理工具,它主要负责构建、依赖管理和项目信息管理。...在`maven_study_01`的学习笔记中,你可以找到更多关于Maven的基础知识和实践案例,帮助你快速上手并掌握这一工具。
maven学习笔记整理
【尚硅谷Maven课程笔记代码资源】是一份全面学习Maven的资料集合,它涵盖了从基础到高级的各种知识点,旨在帮助开发者深入理解并熟练运用Maven进行自动化构建。该资源包含课件、源码和相关的笔记,使得学习过程更加...
** Maven学习笔记详解 ** Maven,作为Java项目管理和构建工具,是开发人员不可或缺的利器。它通过使用一种标准化的项目对象模型(Project Object Model,POM)来管理项目的依赖关系,构建过程以及配置信息。Maven...
在“培训机构传出的maven学习笔记”中,我们可能涵盖以下几个关键知识点: 1. **Maven的基本概念**:理解Maven的核心概念,如POM.xml文件、仓库(本地仓库和中央仓库)、生命周期和构建阶段(如clean、compile、...
**Maven教程:基础篇——尚硅谷学习笔记 2022年** Maven是一个强大的Java项目管理和构建工具,由Apache软件基金会开发。它通过提供一个标准的项目对象模型(Project Object Model,POM)来简化项目的构建过程,并...
【Maven学习笔记1】 Maven是一个强大的Java项目管理和构建工具,它可以帮助开发者管理项目的依赖、构建过程、项目信息和报告。本笔记主要涵盖了Maven的基础知识,包括资料收集、安装指南,特别是针对Linux环境下的...
【mybatis_maven学习笔记】 在Java开发领域,MyBatis和Maven是两个不可或缺的工具,它们分别在数据访问层和项目构建方面扮演着重要角色。MyBatis是一个优秀的持久层框架,它支持定制化SQL、存储过程以及高级映射,...
内容概要:maven学习笔记,适合刚接触maven的人能让你快速入门。 适用人群:大学生或者初基础maven的人 使用场景及目标:idea集成maven,用来下载依赖包
### 个人Maven学习笔记 #### 为什么使用Maven? 在软件开发过程中,尤其是在使用Java进行后端开发时,项目通常会依赖大量的第三方库或框架。如果没有统一的管理工具,这些依赖很容易出现版本冲突的问题,增加了...
【Maven学习笔记】 Maven是一个强大的项目管理和构建工具,主要应用于Java开发领域。它能够自动管理项目的依赖关系,帮助开发者解决因jar包版本冲突、依赖管理混乱等问题带来的困扰。Maven通过制定一套规范化的项目...
Maven学习笔记,使用中遇到的问题,集成eclipse的各种坑,以便记录,为了以后复习使用。
**Maven学习笔记** Maven是一个强大的Java项目管理和构建工具,它简化了项目的构建、依赖管理和文档生成。本文档基于尚硅谷的视频教程,旨在帮助读者深入理解Maven的核心概念和使用方法。 **1. 为什么学习Maven** ...
**Maven项目学习笔记记录** 在软件开发领域,Maven是一个强大的项目管理和构建工具,尤其在Java开发中广泛使用。本笔记将深入探讨Maven的核心概念、主要功能以及实际应用场景,帮助你更好地理解和掌握这一重要工具...
这本书通过一系列逐步讲解的实例,模拟了开发者之间互相学习、交流的过程,让读者能够快速上手并精通Maven。 Maven的核心概念包括项目对象模型(Project Object Model,POM),这是Maven处理项目配置的主要方式。...