Maven Maven commonly used commands commonly used commands:

Maven commonly used commands:

Maven repository:

http://repo2.maven.org/maven2/

Maven relies query:

http://mvnrepository.com/

A, Maven commonly used commands:

1. Create a plain Java Maven project:

mvn archetype:create
    -DgroupId=packageName
    -DartifactId=projectName

2. Create a Web project Maven:

mvn archetype:create
    -DgroupId=packageName
    -DartifactId=webappName
    -DarchetypeArtifactId=maven-archetype-webapp

3. Reverse maven project generating skeleton:

mvn archetype:generate

  ? How do you create your maven project is not like this:

mvn archetype:create -DarchetypeArtifactId=maven-archetype-quickstart -DgroupId=com.ryanote -Dartifact=common

  If you then, then you're out, and with all the modern mvn archetype: generate, and this project will create more humane boring thing, you no longer need to remember so many of archetypeArtifactId, you just enter the archetype: generate, the rest is done "choice" of.

  cmd steps:

  Abbreviations writing:

mvn archetype:generate -DgroupId=otowa.user.dao -DartifactId=user-dao -Dversion=0.01-SNAPSHOT

4. Compile the source code:

mvn compile

5. Compile the test code:

mvn test-compile

6. Run the test:

mvn test

7. generate site:

mvn site

8. Packaging:

mvn package

9. The jar is mounted in the Local Repository:

mvn install
例:installing D:\xxx\xx.jar to D:\xx\xxxx

10. Clear generated by the project:

mvn clean

11. generate eclipse project:

mvn eclipse:eclipse

12. Generate project idea:

mvn idea:idea

13. The combination of commands goal, not only as packaging test:

mvn -Dtest package

14. Compile content of the test:

mvn test-compile

15. The only jar packaging:

mvn jar:jar

16. The test only without the compiler does not compile test:

mvn test -skipping compile -skipping test-compile
 (-Skipping flexible use, of course, also be used for other combinations of commands) 

17. Some systems purge eclipse settings:

mvn eclipse:clean 

18. View the current project has been resolved dependency:

mvn dependency:list

19. Upload to PW:

mvn deploy

20. The mandatory check for updates, because the snapshot version of the update strategy (updated several times a day, once every other period of time to update) exist, if you want to force an update will use this command: 

mvn clean install-U

21. Source Package:

mvn source:jar
or
mvn source:jar-no-fork

Difference mvn compile with mvn install, mvn deploy the

  1. mvn compile, compiled class files
  2. mvn install, contains mvn compile, mvn package, then upload it to a local warehouse
  3. mvn deploy, contains mvn install, then upload it to PW

Two, PS:

  Generally used is the case, first code via cvs or svn downloaded to the machine, and then execute mvn eclipse: eclipse generating ecllipse project file, and then introduced into eclipse on the line; performed after modifying the code mvn compile or mvn test inspection, can download eclipse the maven plugin.

1. Display version information:

mvn -version/-v

2. Create mvn project:

mvn archetype:create -DgroupId=com.oreilly -DartifactId=my-app

3. Generate target directory, compile, test code, generate test reports, generated jar / war file:

mvn package

4. Run the project on the jetty:

mvn jetty:run

The display detailed error message:

mvn -e

6. Verify that the project is correct and that all required resources are available:

mvn validate

7. Handling and publish packages in integrated test environment can run in:

mvn integration-test

8. Run any checks to verify whether the packet is valid and to meet quality standards:

mvn verify

9. any additional source code application needs, such as xdoclet:

mvn generate-sources

10. Use the help of plug-ins to describe the target output Maven Help plugin:

mvn help:describe -Dplugin=help

11. Use Help complete plugin output targets with parameters column:

mvn help:describe -Dplugin=help -Dfull

12. Obtain information for a single destination, setting parameters and mojo plugin parameters. This command lists all the information compile goal of the Compiler plugin:

mvn help:describe -Dplugin=compiler -Dmojo=compile -Dfull

13. All Maven Exec lists the target plug-ins are available:

mvn help:describe -Dplugin=exec -Dfull

14. Look at this, "valid (effective)" POM, it exposes Maven's default settings:

mvn help:effective-pom

15. For a complete dependence trail, including those components because of a conflict or other reasons be rejected introduced to open the Debug mark of running Maven:

mvn install -X

16. Add maven.test.skip property to any goal you can skip the test:

mvn install -Dmaven.test.skip=true

17. Construction of assembly Maven Assembly Plugin is a plug-in to create your application-specific bundles:

mvn install assembly:assembly

18. Plug-generated Wtp Web project:

mvn -Dwtpversion=1.0 eclipse:eclipse

19. Clear the configuration information Eclipse Project (Web project):

mvn -Dwtpversion=1.0 eclipse:clean

20. The project into Eclipse projects:

mvn eclipse:eclipse

21. mvn exec commands can be executed in the project main functions:

First, we need to compile java project: mvn compile
The absence of parameters: mvn exec: java -Dexec.mainClass = ". *** Main"
There is a parameter: mvn exec: java -Dexec.mainClass = ". *** Main" -Dexec.args = "arg0 arg1 arg2"
Specifies the run-time library: mvn exec: java -Dexec.mainClass = ". *** Main" -Dexec.classpathScope = runtime

22. Print out a list of resolved dependencies:

mvn dependency:resolve

23. Print the entire dependency tree:

mvn dependency:tree

In applications using multiple repositories 

Copy the code
<repositories>    
    <repository>     
        <id>Ibiblio</id>     
        <name>Ibiblio</name>     
        <url>http://www.ibiblio.org/maven/</url>   
    </repository>   
    <repository>     
        <id>PlanetMirror</id>     
        <name>Planet Mirror</name>     
        <url>http://public.planetmirror.com/pub/maven/</url>   
    </repository>  
</repositories>

mvn deploy:deploy-file -DgroupId=com -DartifactId=client -Dversion=0.1.0 -Dpackaging=jar -Dfile=d:\client-0.1.0.jar -DrepositoryId=maven-repository-inner -Durl=ftp://xxxxxxx/opt/maven/repository/
Copy the code

Jar to publish third-party local library

mvn install:install-file -DgroupId=com -DartifactId=client -Dversion=0.1.0 -Dpackaging=jar -Dfile=d:\client-0.1.0.jar


-DdownloadSources=true

-DdownloadJavadocs=true

Third, additional

mvn help:describe

Because if you can not remember what a plugin goal and painful too, because if you can not remember what parameters have a goal and distress, then try this command it, it will tell you everything.

Parameters: 1. -Dplugin = pluginName 2. -Dgoal (or -Dmojo) = goalName: used with -Dplugin, it lists information about a plug-in goal,

If you find it is not detailed enough, can also be added -Ddetail (Note: a plugin goal is also considered a "Mojo").

Here everyone would run mvn help: describe -Dplugin = help -Dmojo = describe feelings about it!

mvn tomcat:run

After using maven, you'll never need to run a web project (practical work often find use it without synchronization update will appear) in the eclipse with tomcat, in the corresponding directory just run mvn tomat: run the command, then you can run in the browser view that if you want more customization, can be configured in the pom.xml file in Riga following:

01 02 03 04 org.codehaus.mojo 05 tomcat-maven-plugin 06 07 / web 08 9090 09 10 11 12 Of course, you can also order Riga parameters to achieve specific functions,

Here are several commonly used:

  1> to skip the test: -Dmaven.test.skip (= true)

  2> designated port:. -Dmaven.tomcat.port = 9090

  3> ignore test failed:. -Dmaven.test.failure.ignore = true, of course, if you have had other associated project updates, be sure to run mvn clean install in the project root directory to perform the update, and then run mvn tomcat: run for the changes to take effect.

mvnDebug tomcat:run

This command is mainly used for remote testing, it listens on port 8000 of remote testing, remote testing in the open after the eclipse, it will run up, set breakpoints, debug, everything is so simple. Mentioned above several parameters that apply equally here.

mvn dependency:sources

Name suggests, with it, you do not have to find that source, and run the source code in your project depends on the package have a jar

Maven repository:

http://repo2.maven.org/maven2/

Maven relies query:

http://mvnrepository.com/

A, Maven commonly used commands:

1. Create a plain Java Maven project:

mvn archetype:create
    -DgroupId=packageName
    -DartifactId=projectName

2. Create a Web project Maven:

mvn archetype:create
    -DgroupId=packageName
    -DartifactId=webappName
    -DarchetypeArtifactId=maven-archetype-webapp

3. Reverse maven project generating skeleton:

mvn archetype:generate

  ? How do you create your maven project is not like this:

mvn archetype:create -DarchetypeArtifactId=maven-archetype-quickstart -DgroupId=com.ryanote -Dartifact=common

  If you then, then you're out, and with all the modern mvn archetype: generate, and this project will create more humane boring thing, you no longer need to remember so many of archetypeArtifactId, you just enter the archetype: generate, the rest is done "choice" of.

  cmd steps:

  Abbreviations writing:

mvn archetype:generate -DgroupId=otowa.user.dao -DartifactId=user-dao -Dversion=0.01-SNAPSHOT

4. Compile the source code:

mvn compile

5. Compile the test code:

mvn test-compile

6. Run the test:

mvn test

7. generate site:

mvn site

8. Packaging:

mvn package

9. The jar is mounted in the Local Repository:

mvn install
例:installing D:\xxx\xx.jar to D:\xx\xxxx

10. Clear generated by the project:

mvn clean

11. generate eclipse project:

mvn eclipse:eclipse

12. Generate project idea:

mvn idea:idea

13. 组合使用goal命令,如只打包不测试:

mvn -Dtest package

14. 编译测试的内容:

mvn test-compile

15. 只打jar包:

mvn jar:jar

16. 只测试而不编译,也不测试编译:

mvn test -skipping compile -skipping test-compile
 ( -skipping 的灵活运用,当然也可以用于其他组合命令) 

17. 清除eclipse的一些系统设置:

mvn eclipse:clean 

18.查看当前项目已被解析的依赖:

mvn dependency:list

19.上传到私服:

mvn deploy

20. 强制检查更新,由于快照版本的更新策略(一天更新几次、隔段时间更新一次)存在,如果想强制更新就会用到此命令: 

mvn clean install-U

21. 源码打包:

mvn source:jar
mvn source:jar-no-fork

mvn compile与mvn install、mvn deploy的区别

  1. mvn compile,编译类文件
  2. mvn install,包含mvn compile,mvn package,然后上传到本地仓库
  3. mvn deploy,包含mvn install,然后,上传到私服

二,PS:

  一般使用情况是这样,首先通过cvs或svn下载代码到本机,然后执行mvn eclipse:eclipse生成ecllipse项目文件,然后导入到eclipse就行了;修改代码后执行mvn compile或mvn test检验,也可以下载eclipse的maven插件。

1. 显示版本信息 :

mvn -version/-v

2. 创建mvn项目:

mvn archetype:create -DgroupId=com.oreilly -DartifactId=my-app

3. 生成target目录,编译、测试代码,生成测试报告,生成jar/war文件 :

mvn package

4. 运行项目于jetty上:

mvn jetty:run

5. 显示详细错误 信息:

mvn -e

6. 验证工程是否正确,所有需要的资源是否可用:

mvn validate

7. 在集成测试可以运行的环境中处理和发布包:

mvn integration-test

8. 运行任何检查,验证包是否有效且达到质量标准:

mvn verify

9. 产生应用需要的任何额外的源代码,如xdoclet :

mvn generate-sources

10. 使用 help 插件的  describe 目标来输出 Maven Help 插件的信息:

mvn help:describe -Dplugin=help

11. 使用Help 插件输出完整的带有参数的目标列 :

mvn help:describe -Dplugin=help -Dfull

12. 获取单个目标的信息,设置  mojo 参数和  plugin 参数。此命令列出了Compiler 插件的compile 目标的所有信息 :

mvn help:describe -Dplugin=compiler -Dmojo=compile -Dfull

13. 列出所有 Maven Exec 插件可用的目标:

mvn help:describe -Dplugin=exec -Dfull

14. 看这个“有效的 (effective)”POM,它暴露了 Maven的默认设置 :

mvn help:effective-pom

15. 想要查看完整的依赖踪迹,包含那些因为冲突或者其它原因而被拒绝引入的构件,打开 Maven 的调试标记运行 :

mvn install -X

16. 给任何目标添加maven.test.skip 属性就能跳过测试 :

mvn install -Dmaven.test.skip=true

17. 构建装配Maven Assembly 插件是一个用来创建你应用程序特有分发包的插件 :

mvn install assembly:assembly

18. 生成Wtp插件的Web项目 :

mvn -Dwtpversion=1.0 eclipse:eclipse

19. 清除Eclipse项目的配置信息(Web项目) :

mvn -Dwtpversion=1.0 eclipse:clean

20. 将项目转化为Eclipse项目 :

mvn eclipse:eclipse

21. mvn exec命令可以执行项目中的main函数 :

首先需要编译java工程:mvn compile
不存在参数的情况下:mvn exec:java -Dexec.mainClass="***.Main"
存在参数:mvn exec:java -Dexec.mainClass="***.Main" -Dexec.args="arg0 arg1 arg2"
指定运行时库:mvn exec:java -Dexec.mainClass="***.Main" -Dexec.classpathScope=runtime

22. 打印出已解决依赖的列表 :

mvn dependency:resolve

23. 打印整个依赖树 :

mvn dependency:tree

在应用程序用使用多个存储库 

Copy the code
<repositories>    
    <repository>     
        <id>Ibiblio</id>     
        <name>Ibiblio</name>     
        <url>http://www.ibiblio.org/maven/</url>   
    </repository>   
    <repository>     
        <id>PlanetMirror</id>     
        <name>Planet Mirror</name>     
        <url>http://public.planetmirror.com/pub/maven/</url>   
    </repository>  
</repositories>

mvn deploy:deploy-file -DgroupId=com -DartifactId=client -Dversion=0.1.0 -Dpackaging=jar -Dfile=d:\client-0.1.0.jar -DrepositoryId=maven-repository-inner -Durl=ftp://xxxxxxx/opt/maven/repository/
Copy the code

发布第三方Jar到本地库中

mvn install:install-file -DgroupId=com -DartifactId=client -Dversion=0.1.0 -Dpackaging=jar -Dfile=d:\client-0.1.0.jar


-DdownloadSources=true

-DdownloadJavadocs=true

三,附加

mvn help:describe

你是否因为记不清某个插件有哪些goal而痛苦过,你是否因为想不起某个goal有哪些参数而苦恼,那就试试这个命令吧,它会告诉你一切的.

参数: 1. -Dplugin=pluginName   2. -Dgoal(或-Dmojo)=goalName:与-Dplugin一起使用,它会列出某个插件的goal信息,

如果嫌不够详细,同样可以加-Ddetail.(注:一个插件goal也被认为是一个 “Mojo”)

下面大家就运行mvn help:describe -Dplugin=help -Dmojo=describe感受一下吧!

mvn tomcat:run

After using maven, you'll never need to run a web project (practical work often find use it without synchronization update will appear) in the eclipse with tomcat, in the corresponding directory just run mvn tomat: run the command, then you can run in the browser view that if you want more customization, can be configured in the pom.xml file in Riga following:

01 02 03 04 org.codehaus.mojo 05 tomcat-maven-plugin 06 07 / web 08 9090 09 10 11 12 Of course, you can also order Riga parameters to achieve specific functions,

Here are several commonly used:

  1> to skip the test: -Dmaven.test.skip (= true)

  2> designated port:. -Dmaven.tomcat.port = 9090

  3> ignore test failed:. -Dmaven.test.failure.ignore = true, of course, if you have had other associated project updates, be sure to run mvn clean install in the project root directory to perform the update, and then run mvn tomcat: run for the changes to take effect.

mvnDebug tomcat:run

This command is mainly used for remote testing, it listens on port 8000 of remote testing, remote testing in the open after the eclipse, it will run up, set breakpoints, debug, everything is so simple. Mentioned above several parameters that apply equally here.

mvn dependency:sources

Name suggests, with it, you do not have to find that source, and run the source code in your project depends on the package have a jar

Guess you like

Origin www.cnblogs.com/mark5/p/11670927.html