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工程
  • 相关阅读:
    vue---mixins的用法
    vue---slot,slot-scoped,以及2.6版本之后插槽的用法
    Java实现DDD中UnitOfWork
    redis基础及redis特殊场景使用描述
    网易一千零一夜 读后初感
    产品经理与众不同的思维方式与“职业病”——《人人都是产品经理》
    【Ubuntu14】Nginx+PHP5+Mysql记录
    A标签/按钮防止重复提交&页面Loading制作
    PHPCMS v9 二次开发_验证码结合Session开发
    eclipse 编码设置【转】
  • 原文地址:https://www.cnblogs.com/bass6/p/7904306.html
Copyright © 2011-2022 走看看