Detailed explanation of Maven commonly used commands

Apache Maven is a software project management and understanding tool. Based on the concept of the project object model (POM), Maven can manage project construction, reporting and documentation from a central information.

Maven advantages:

  • Convention is better than configuration
  • Test support
  • Simple to build
  • Rich plugins

Maven commonly used commands:

2. Create a Maven web project: 
    mvn archetype: create
    -DgroupId = packageName   
    -DartifactId = webappName
    -DarchetypeArtifactId = maven-archetype-webapp   
3. Compile the source code: mvn compile
4. Compile the test code: mvn test-compile   
5. Run the test : Mvn test 
6. Generate site: mvn site 
7. Package: mvn package 
8. Install jar in local repository: mvn install
9. Clear the generated project: mvn clean 
10. Generate eclipse project: mvn eclipse: eclipse 
11. Generate idea Project: mvn idea: idea 
12. Use the goal command in combination, such as only packaging and not testing: mvn -Dtest package 
13. Compile and test content: mvn test-compile 
14. Only play jar package: mvn jar: jar 
15. Only test and Do not compile or test compile: mvn test -skipping compile -skipping test-compile
      (flexible use of -skipping, of course, can also be used for other combined commands) 
16. Clear some system settings of eclipse: mvn eclipse: clean 

ps: The
general usage is like this, first download the code to the machine through cvs or svn, then execute mvn eclipse: eclipse to generate the ecllipse project file, and then import it into eclipse; after modifying the code, execute mvn compile or mvn test to verify Download the maven plugin for eclipse.

mvn -version / -v display version information
mvn archetype: generate create mvn project
mvn archetype: create -DgroupId = com.oreilly -DartifactId = my-app create mvn project

mvn package Generate target directory, compile and test code, generate test report, generate jar / war file
mvn jetty: run Run the project on jetty,
mvn compile compile
mvn test compile and test
mvn clean Clear the generated files
mvn site Generate project related information Website
mvn -Dwtpversion = 1.0 eclipse: eclipse Web project to generate Wtp plugin
mvn -Dwtpversion = 1.0 eclipse: clean Clear configuration information of Eclipse project (Web project)

mvn -DskipTests, do not execute test cases, but compile test case classes to generate corresponding class files to target / test-classes.

mvn -Dmaven.test.skip = true, do not execute test cases, and do not compile test case classes.
mvn eclipse: eclipse converts the project to an Eclipse project

在应用程序用使用多个存储库
<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/

Publish the third-party Jar to the 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

mvn -e displays detailed error information.

mvn -U Force update dependent packages

mvn -B This parameter indicates that Maven uses batch mode to build the project
mvn validate to verify that the project is correct and that all required resources are available.
mvn test-compile compiles the project test code. .
mvn integration-test processes and publishes packages in an environment where integration tests can run.
mvn verify runs any checks to verify that the package is valid and meets quality standards.   
mvn generate-sources generates any additional source code needed by the application, such as xdoclet.

Summary of common commands:

mvn -v displays the version
mvn help: describe -Dplugin = help uses the describe goal of the help plugin to output the information of the Maven Help plugin.
mvn help: describe -Dplugin = help -Dfull Use the Help plugin to output the complete target column with parameters.
mvn help: describe -Dplugin = compiler -Dmojo = compile -Dfull Get the information of a single target, set mojo parameters and plugin parameters. This command lists all the information about the compile goal of the Compiler plugin
mvn help: describe -Dplugin = exec -Dfull lists all the goals available for the Maven Exec plugin
mvn help: effective-pom Look at this "effective" POM, it Maven's default settings are exposed

mvn archetype: create -DgroupId = org.sonatype.mavenbook.ch03 -DartifactId = simple -DpackageName = org.sonatype.mavenbook Create a normal Java project of Maven, use the Maven Archetype plugin
mvn exec: java -Dexec.mainClass = org on the command line .sonatype.mavenbook.weather.Main Exec plugin allows us to run this program without loading the appropriate dependencies into the classpath
mvn dependency: resolve prints out the list of resolved dependencies
mvn dependency: tree prints the entire dependency tree

mvn install -X Want to view the complete dependency trail, including those components that were rejected due to conflicts or other reasons, open the Maven debug flag and run
mvn install -Dmaven.test.skip = true to add maven.test to any target. The skip attribute can skip the test
mvn install assembly: assembly build assembly Maven Assembly plugin is a plugin used to create a unique distribution package for your application

mvn jetty: run Call the Run target of the Jetty plugin to start the web application in the Jetty Servlet container
mvn compile compile your project
mvn clean install delete and then compile

mvn hibernate3: hbm2ddl uses the Hibernate3 plugin to construct the database

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

Maven dependency query: http://mvnrepository.com/

Guess you like

Origin www.linuxidc.com/Linux/2020-04/162861.htm