创建项目

mvn archetype:generate

首次运行时,mvn会从远程"中央仓库"下载一些必需的文件到"本地仓库",下载完成后(下一篇会讲解如何,在局域网环境中搭建“私服”,直接从局域网的代理仓库中下载这些依赖项),会自动进入交互模式,会让你输入一些基本信息, 类似如下:

Confirm properties configuration:
groupId: quanzaiyu
artifactId: quanzaiyu
version: 1.0-SNAPSHOT
package: com.test
 Y: : y
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Old (1.x) Archetype: maven-archetype-quickstart:1.1
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: basedir, Value: D:\Workplace\my_test\_JAVA\MavenTest
[INFO] Parameter: package, Value: com.test
[INFO] Parameter: groupId, Value: quanzaiyu
[INFO] Parameter: artifactId, Value: quanzaiyu
[INFO] Parameter: packageName, Value: com.test
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] project created from Old (1.x) Archetype in dir: D:\Workplace\my_test\_JAVA\MavenTest\quanzaiyu
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  08:10 min
[INFO] Finished at: 2019-06-03T23:15:48+08:00
[INFO] ------------------------------------------------------------------------

随后将生成如下目录结构

quanzaiyu
└─src
    ├─main
    │  └─java
    │      └─com
    │          └─test
    └─test
        └─java
            └─com
                └─test

还生成了3个文件:

  • pom.xml 依赖配置文件
  • src/main/java/com/test/App.java 主程序
  • src/test/java/com/test/AppTest.java 单元测试

编译、打包后生成的文件将存放于 src/target

MIT Licensed | Copyright © 2018-present 滇ICP备16006294号

Design by Quanzaiyu | Power by VuePress