Maven
首先需要对maven的命令语法有个清晰的认识运行Mave命令的语法格式如下:mvn [options] [
创建maven工程1)使用maven命令创建工程:需要使用到maven-archetype-quickstart插件mvn archetype:generate -DgroupId=hxb.time -DartifactId=echoTimer -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false执行完命令后,maven会开始处理并下载相关的依赖包并在当前目录项建立完整的Java工程项目结构,另外这个工程是可以导入到eclipse开发环境中的2)使用eclipse maven插件创建工程通过菜单建立新的Maven工程:File -》 New -》Maven Project
编译Maven工程使用命令:maven compileE:\test\echoTimer>mvn compile[INFO] Scanning for projects...[INFO][INFO] ------------------------------------------------------------------------[INFO] Building echoTimer 1.0-SNAPSHOT[INFO] ------------------------------------------------------------------------[INFO][INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ echoTimer ---[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent![INFO] skip non existing resourceDirectory E:\test\echoTimer\src\main\resources[INFO][INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ echoTimer ---[INFO] Changes detected - recompiling the module![WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent![INFO] Compiling 1 source file to E:\test\echoTimer\target\classes[INFO] ------------------------------------------------------------------------[INFO] BUILD SUCCESS[INFO] ------------------------------------------------------------------------[INFO] Total time: 2.790 s[INFO] Finished at: 2017-12-29T15:54:26+08:00[INFO] Final Memory: 11M/27M[INFO] ------------------------------------------------------------------------
打包Maven工程,将工程输出为应用包文件使用命令:maven packageE:\test\echoTimer>mvn package[INFO] Scanning for projects...[INFO][INFO] ------------------------------------------------------------------------[INFO] Building echoTimer 1.0-SNAPSHOT[INFO] ------------------------------------------------------------------------[INFO][INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ echoTimer ---[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent![INFO] skip non existing resourceDirectory E:\test\echoTimer\src\main\resources[INFO][INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ echoTimer ---[INFO] Nothing to compile - all classes are up to date[INFO][INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ echoTimer ---[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent![INFO] skip non existing resourceDirectory E:\test\echoTimer\src\test\resources[INFO][INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ echoTimer ---[INFO] Changes detected - recompiling the module![WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent![INFO] Compiling 1 source file to E:\test\echoTimer\target\test-classes[INFO][INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ echoTimer ---[INFO] Surefire report directory: E:\test\echoTimer\target\surefire-reportsDownloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-junit3/2.12.4/surefire-junit3-2.12.4.pomDownloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-junit3/2.12.4/surefire-junit3-2.12.4.pom (1.7 kB at 171 B/s)Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-providers/2.12.4/surefire-providers-2.12.4.pomDownloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-providers/2.12.4/surefire-providers-2.12.4.pom (2.3 kB at 2.4 kB/s)Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-junit3/2.12.4/surefire-junit3-2.12.4.jarDownloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-junit3/2.12.4/surefire-junit3-2.12.4.jar (26 kB at 6.6 kB/s)------------------------------------------------------- T E S T S-------------------------------------------------------Running hxb.time.AppTestTests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.005 secResults :Tests run: 1, Failures: 0, Errors: 0, Skipped: 0[INFO][INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ echoTimer ---[INFO] Building jar: E:\test\echoTimer\target\echoTimer-1.0-SNAPSHOT.jar[INFO] ------------------------------------------------------------------------[INFO] BUILD SUCCESS[INFO] ------------------------------------------------------------------------[INFO] Total time: 18.273 s[INFO] Finished at: 2017-12-29T16:02:50+08:00[INFO] Final Memory: 14M/34M[INFO] ------------------------------------------------------------------------