Maven common commands and applications in eclipse

Source: Internet
Author: User

1. Common commands

MVN archetype: Generate--Build project MVN clean--Project Cleanup mvn test--Project Unit test compilation MVN compile--Project source code compilation MVN package--Project package MVN install--release project submitted to local warehouse MVN deploy--Publish project to MVN jetty: Run--Start jetty container mvn eclipse: Clean--clear some of Eclipse's system settings mvn Eclipse: Eclipse--Generate Eclipse project file mvn idea: Clean--Clear some system settings for idea MVN idea: Idea--Generate Idea Project file mvn dependency: Tree--View dependency tree MVN Assembly: Assembly--Requires a assembly plugin that can be used to package the specified file tar.gz,Zip Package//Specify maven parameters:-dskiptests=true--default unit Test-P local--Select resource file type local, you need to open the resource configuration in POM

Tip 1: For MAVEN parameters, the uppercase d in front of the parameter is the symbol that passes the parameter, followed by the real name of the parameter, this argument can refer to "Maven combat" a book, there is a detailed explanation. Links: https://item.jd.com/10476794.html

Tip 2: Personal understanding, MAVEN is actually a combination of plug-in mechanism, such as Archetype,eclipse,jetty,idea these, each represents a plug-in. For example, why archetype use grenrate, and parameters to pass the generation, direct search: Maven archetype plugin.

When prompted 3:maven executes, there are sequential, such as MVN clean test compile, if you run MVN compile separately, the clean,test command is executed by default.

2, commonly used to build project Skeleton command

Build Application project: MVN archetype: Generate -darchetypecatalog=internal-darchetypeartifactid=  Maven-archetype-quickstart  Build Web project: mvn archetype: Generate -darchetypecatalog=internal- Darchetypeartifactid=maven-archetype-webapp  

Tip 1: As explained above, archetype is essentially a plugin, then we can directly search the usage of this plugin, official link: http://maven.apache.org/guides/introduction/ Introduction-to-archetypes.html, on the right side of the page, if you have hyperlinks, you can click to see other extension instructions.

Tip 2: And for Maven-archetype-quickstart These parameters, is also available on the official website, reference: http://maven.apache.org/archetypes/index.html, which explicitly gives the example and the meaning of creating folders represents what.

When the above command executes, you are prompted to enter Groupid,artifactid this information, and then enter it to complete.

For example, if we want to generate a project skeleton by default, it can be the following command:

MVN archetype: Generate -darchetypecatalog=internal-dgroupid= (project group) com.jsoft.testproject-dartifactid= (project name /module Name) testmaven-dversion= (version number) 1.0-snapshot  -dpackage= (package name) Testpackage

Tip 1: The above creation is a Maven-archetype-quickstart-based project.

Tip 2: Similarly, after testing, whether it is a new QuickStart project or a WebApp project, as long as the folder is new.

3. Folder description for MAVEN project

A standard MAVEN project with QuickStart as the main folder directory structure is as follows:

The directory structure of the WebApp project is as follows:

Note: The WebApp project will have an extra WebApp folder on the main folder, and the WebApp folder will not appear on the test folder, which means that the unit test is the test logic code.

And if you use the MAVEN command to create a new WebApp project, the default is not with the test folder, the test folder can be created later, for why not new, in fact, the official default does not. Reference:

http://maven.apache.org/archetypes/maven-archetype-webapp/

Http://stackoverflow.com/questions/3042518/maven-archetype-webapp-eclipse-problem here also made a note, It is also consistent for the Test folder to create its own new effect.

The above content reference: http://yanan0628.iteye.com/blog/2270344

4. The application of Maven in eclipse

In the latest version of Eclipse, the plugins that have been integrated with MAVEN by default can be easily integrated with various commands. The eclipse is as follows:

For example, to execute a mvn compile command, the action is: Maven build ..., note: Here Maven build is to execute the last command, so do not mistake; then enter compile

Appears as above built, proves to have succeeded.

For WebApp projects, you can test with run as server, and if your project doesn't work, it's definitely not a successful configuration.

Most of the time we have not tested with Tomcat, and instead use faster and lighter jetty, such as MVN Jetty:run.

Maven common commands and applications in eclipse

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.