zoukankan      html  css  js  c++  java
  • 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工程
  • 相关阅读:
    css属性设置
    自由从摇篮开始 ——杨支柱
    提醒幸福
    随记
    那些回不去的年少时光(桐华)
    Javascript 与正则表达式
    XmlHttpRequest对象的获取及相关操作
    CSS的4种引入方式及优先级
    c#textBox控件限制只允许输入数字及小数点,是否为空
    c# 循环界面控件
  • 原文地址:https://www.cnblogs.com/bass6/p/7904306.html
Copyright © 2011-2022 走看看