maven创建helloword项目
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | [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 |
进到项目中,然后进行:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | # 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包查看结果
1 2 | # java -cp target/helloworld-1.0v.jar helloword.App Hello World! |
这里列举几个常用的命令
mvn compile 编译项目
mvn test 编译运行单元测试
mvn package 打包(jar or war)
mvn install 将项目安装到本地仓库
mvn clean 清空项目
mvn eclipse:eclipse 生成eclipse工程
联系方式QQ:326528263 EMAIL:clnking@163.com 网名:bass 分享技术 突破难点 创新思维
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 字符编码:从基础到乱码解决