Maven常用命令
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Maven常用命令
1、mvn clean compile
说明:clean 清理输出目录/target,compile 编译项目主代码到target/classes。
执行mvn clean compile命令的结果:
E:\Java学习\Workspace\myProject>mvn clean compile
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building myProject 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ myProject ---
[INFO] Deleting E:\Java学习\Workspace\myProject\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ myProject--- [WARNING] Using platform encoding (GBK 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) @ myProject ---
[WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent!
[INFO] Compiling 1 source file to E:\Java学习\Workspace\myProject\target\classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.218s
[INFO] Finished at: Thu Aug 29 21:32:54 CST 2013
[INFO] Final Memory: 5M/11M
[INFO] ------------------------------------------------------------------------
E:\Java学习\Workspace\myProject>
2、mvn clean test
说明:test调用Maven执行测试
E:\Java学习\Workspace\myProject>mvn clean test
[INFO] Scanning for projects...
[INFO]
[INFO] Building myProject 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ myProject ---
[INFO] Deleting E:\Java学习\Workspace\myProject\target
[INFO]
[INFO] --- maven-resources-plugin:2.3:resources (default-resources) @ myProject---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ myProject ---
[WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent!
[INFO] Compiling 1 source file to E:\Java学习\Workspace\myProject\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.3:testResources (default-testResources) @ myProject --- [INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ myProject --- [INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ myProject ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.438s
[INFO] Finished at: Fri Aug 30 22:15:29 CST 2013
[INFO] Final Memory: 8M/24M
[INFO] ------------------------------------------------------------------------
E:\Java学习\Workspace\myProject>
3、mvn clean package
说明:package使用Maven打jar包
E:\Java学习\Workspace\myProject>mvn clean package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building myProject 0.0.1-SNAPSHOT
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ myProject ---
[INFO] Deleting E:\Java学习\Workspace\myProject\target
[INFO]
[INFO] --- maven-resources-plugin:2.3:resources (default-resources) @ myProject---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ myProject ---
[WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent!
[INFO] Compiling 1 source file to E:\Java学习\Workspace\myProject\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.3:testResources (default-testResources) @ myProject --- [INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ myProject --- [INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ myProject ---
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ myProject ---
[INFO] Building jar: E:\Java学习\Workspace\myProject\target\myProject-0.0.1-SNAPSHOT.jar [INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.140s
[INFO] Finished at: Fri Aug 30 22:34:31 CST 2013
[INFO] Final Memory: 9M/23M
[INFO] ------------------------------------------------------------------------
E:\Java学习\Workspace\myProject>
4、mvn clean install
说明:install将项目jar包发布到本地仓库中
5、java –jar 项目.jar
E:\Java学习\Workspace\myProject>cd target
E:\Java学习\Workspace\myProject\target>dir
驱动器E 中的卷是资料
卷的序列号是EC10-1C79
E:\Java学习\Workspace\myProject\target 的目录
2013-08-30 22:48 <DIR> .
2013-08-30 22:48 <DIR> ..
2013-08-30 22:48 <DIR> classes
2013-08-30 22:48 <DIR> generated-sources
2013-08-30 22:48 <DIR> maven-archiver
2013-08-30 22:48 3,599 myProject-0.0.1-SNAPSHOT.jar
2013-08-30 22:48 3,328 original-myProject-0.0.1-SNAPSHOT.jar
2013-08-30 22:48 <DIR> test-classes
2 个文件6,927 字节
6 个目录32,985,837,568 可用字节
E:\Java学习\Workspace\myProject\target>java -jar myProject-0.0.1-SNAPSHOT.jar
Hello Maven
E:\Java学习\Workspace\myProject\target>
6、mvn dependency:list
说明:查看当前Maven项目的已解析依赖
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.huawei.smartcare:account-email:jar:0.0.1-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 48, column 12
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building account-email 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:list (default-cli) @ account-email ---
[INFO]
[INFO] The following files have been resolved:
[INFO] org.springframework:spring-context:jar:2.5.6:compile
[INFO] aopalliance:aopalliance:jar:1.0:compile
[INFO] junit:junit:jar:4.7:test
[INFO] org.springframework:spring-context-support:jar:2.5.6:compile
[INFO] javax.activation:activation:jar:1.1:compile
[INFO] com.icegreen:greenmail:jar:1.3.1b:test
[INFO] org.springframework:spring-core:jar:2.5.6:compile
[INFO] org.slf4j:slf4j-api:jar:1.3.1:test
[INFO] javax.mail:mail:jar:1.4.1:compile
[INFO] org.springframework:spring-beans:jar:2.5.6:compile
[INFO] commons-logging:commons-logging:jar:1.1.1:compile
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.516s
[INFO] Finished at: Mon Sep 02 11:46:13 CST 2013
[INFO] Final Memory: 8M/20M
[INFO] ------------------------------------------------------------------------
7、mvn dependency:tree
说明:查看当前Maven项目的依赖树
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.huawei.smartcare:account-email:jar:0.0.1-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 48, column 12
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building account-email 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ account-email --- [INFO] com.huawei.smartcare:account-email:jar:0.0.1-SNAPSHOT [INFO] +- org.springframework:spring-core:jar:2.5.6:compile
[INFO] | \- commons-logging:commons-logging:jar:1.1.1:compile [INFO] +- org.springframework:spring-beans:jar:2.5.6:compile
[INFO] +- org.springframework:spring-context:jar:2.5.6:compile
[INFO] | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- org.springframework:spring-context-support:jar:2.5.6:compile [INFO] +- javax.mail:mail:jar:1.4.1:compile
[INFO] | \- javax.activation:activation:jar:1.1:compile
[INFO] +- junit:junit:jar:4.7:test
[INFO] \- com.icegreen:greenmail:jar:1.3.1b:test
[INFO] \- org.slf4j:slf4j-api:jar:1.3.1:test
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.875s
[INFO] Finished at: Mon Sep 02 11:45:04 CST 2013
[INFO] Final Memory: 8M/20M
[INFO] ------------------------------------------------------------------------
8、mvn dependency:analyze
说明:分析当前项目的依赖
9、mvn help:describe -Dplugin=compiler
说明:查看插件的描述信息。