[root@666 maven_work]# mvn archetype:create -DgroupId=helloword -DartifactId=helloworld [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.493 s [INFO] Finished at: 2017-11-27T14:46:23+08:00 [INFO] Final Memory: 7M/145M [INFO] ------------------------------------------------------------------------ [ERROR] Could not find goal 'create' in plugin org.apache.maven.plugins:maven-archetype-plugin:3.0.1 among available goals crawl, create-from-project, generate, help, integration-test, jar, update-local-catalog -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoNotFoundException 以create報錯 [root@666 maven_work]# mvn archetype:create -DgroupId=helloword -DartifactId[root@666 maven_work]# mvn archetype:generate -DgroupId=helloword -DartifactId=helloworld 成功!! 生成如下文件: # tree helloworld/ helloworld/ |-- pom.xml `-- src |-- main | `-- java | `-- helloword | `-- App.java `-- test `-- java `-- helloword `-- AppTest.java 7 directories, 3 files
進到項目中,而後進行:java
# cd helloworld/ [root@666 helloworld]# ls pom.xml src [root@666 helloworld]# mvn package 第一次編譯的話,須要聯網,由於Maven會自動下載依賴包.成功後會生成:target文件夾 [root@666 helloworld]# ls pom.xml src target [root@666 helloworld]# tree target/ target/ |-- classes | `-- helloword | `-- App.class |-- helloworld-1.0v.jar |-- maven-archiver | `-- pom.properties |-- maven-status | `-- maven-compiler-plugin | |-- compile | | `-- default-compile | | |-- createdFiles.lst | | `-- inputFiles.lst | `-- testCompile | `-- default-testCompile | |-- createdFiles.lst | `-- inputFiles.lst |-- surefire-reports | |-- helloword.AppTest.txt | `-- TEST-helloword.AppTest.xml `-- test-classes `-- helloword `-- AppTest.class 12 directories, 10 files
手動運行jar包查看結果apache
# java -cp target/helloworld-1.0v.jar helloword.App Hello World!
這裏列舉幾個經常使用的命令eclipse