maven创建helloword项目

[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

 进到项目中,然后进行:

# 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包查看结果

# 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工程

转载于:https://www.cnblogs.com/bass6/p/7904306.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值