• maven的常用命令


    1. 创建Maven的普通java项目:mvn archetype:create -DgroupId=“xx” -DartifactId=“xx”-DpackageName="xx" -Dversion="xx"

    2. 创建Maven的Web项目:mvn archetype:create -DgroupId=“xx”-DartifactId=“xx”-DpackageName="xx" -Dversion="xx"-DarchetypeArtifactId=maven-archetype-webapp

    3. 编译源代码: mvn compile
    4. 编译测试代码:mvn test-compile
    5. 运行测试:mvn test
    6. 产生site:mvn site
    7. 打包:mvn package (一般直接使用: mvn clean package )
    8. 清除产生的项目:mvn clean
    9. 生成eclipse项目:mvn eclipse:eclipse
    10.只打jar包: mvn jar:jar
    11.当开发一个带有很多失败单元测试的系统 mvn test -Dmaven.test.failure.ignore=true

    (可以在pom.xml中配置build标签

    <build>
    <plugins>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
    <testFailureIgnore>true</testFailureIgnore>
    </configuration>
    </plugin>
    </plugins>
    </build>

    )
    12.想要整个的跳过测试 mvn install -Dmaven.test.skip=true

    (可以在pom.xml中配置build标签

    <build>
    <plugins>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
    <skip>true</skip>
    </configuration>
    </plugin>
    </plugins>
    </build>

    )

    13.构建打包好的命令行应用程序

    (1)配置pom.xml
    <build>
    <plugins>
    <plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <configuration>
    <descriptorRefs>
    <descriptorRef>jar-with-dependencies</descriptorRef>
    </descriptorRefs>
    </configuration>
    </plugin>
    </plugins>
    </build>
    (2)运行:mvn install assembly:assembly

    14.运行java主程序:mvn exec:java -Dexec.mainClass=org.sonatype.mavenbook.weather.Main 运行Main.class

    15.查看插件的帮助信息:mvn help:describe -Dplugin=exec -Dfull 查看exec插件的详细信息(关键时刻非常有用的一个插件)

    16. 查看项目所有的依赖插件:mvn dependency:resolve

    17.查看项目依赖插件的目录树:mvn dependency:tree

    18.调试标记运行:mvn install -X

    19.在本地 Repository 中安装 jar:mvn install(一般直接用mvn clean install)

    20.

    src/main/java :是项目编译时默认的编译文件位置。
    src/main/resources :是项目资源文件默认存放的位置。

  • 相关阅读:
    Android手势(上,下,左和右的判断)
    我爱意甲
    程序员特有的9个坏习惯
    我爱英超
    VS2010快捷键总结(一)
    C#中导出Excel总结
    MessageDAL
    GDI+ 绘图总结
    .net中绑定日期时,只显示年月日的做法
    Vb线程控制
  • 原文地址:https://www.cnblogs.com/lvk618/p/4715535.html
Copyright © 2020-2023  润新知