Maven commands with pom file constants

Blowing water in a bowl

Maven commands:
Maven can be used not only on Eclipse, but also by commands in cmd. Although this is very troublesome, and some of them are generally not used, you still need to understand some operation methods that may be used.
1.mvn compile command: This command is used to compile the project. When using this command to compile the project code in cmd, you need to cd into the project directory first, otherwise an error will be reported.
If you use the command to compile the project, the project folder can be created manually by [Learn Java, go to Kaige School kaige123.com]. This manually created style is similar to the style created with Eclipse. The project folder is the main and test folders. There is a pom configuration file. The information in this pom file must be configured correctly. Basically, Maven is identified around this file. The main and test files are the project code and test code. For example, I created a MavenTest2 project:

image

After creating the project according to the regulations, start compiling:

image

The above is the compiled code with the information of successful compilation feedback
:

image

2.mvn test-compile command: This command is used to test the project code under compilation. The test needs to depend on the JUnit package, so you must also configure the pom file and write the dependencies. The dependencies of this package can be found in the central class library , and then you need to create the src folder and put the main and test folders in it:

image

image

Note: Before compiling the test, you need to run the mvn compile command to download the dependent JUnit package, otherwise an error will be reported:

image

Then run the mvn test-compile command:

image

Test the compiled code:

image

3.mvn test command: This command is used to call the test and compile the project code

image

Code testing is mainly to test and verify whether there is a problem with the logical result of the code. If there is no problem, the project can be released.

4.mvn package command: This command will package the project, and a test will be performed when packaging:

image

The packaged package will be placed in this folder:

image

5.mvn jar:jar command: This command only prints the JAR package, and the same typed jar package will be placed in the target folder:

image

6.mvn clean command: This command is used to clean up project files

image

7.mvn archetype:generate command: This command uses Maven's template skeleton to create a project. To use this command, you need to create a project folder first, and then cd into that folder to execute this command. If you use this command to create a project, you need to download the corresponding package, so you need to wait:

You will then be asked to choose a number or apply a filter, just enter 1:

image

Then enter the project-related information:

image

Created successfully:

image

image

The above is a web page project. If we need to create a javase project, we need to enter 15 in the step of selecting the number. This number represents the skeleton of the javase project:

image

The same information needs to be entered:

image

Created successfully:

image

image

The project code that comes with the project skeleton:

image

The following are the project skeleton numbers in Maven:
1: internal -> appfuse-basic-jsf (creates a prototype of a web application based on Hibernate, Spring and JSF)
2: internal -> appfuse-basic-spring (creates a prototype based on Hibernate, Spring and Spring MVC web application prototype)
3: internal -> appfuse-basic-struts (creates a Hibernate, Spring and Struts 2 based web application prototype)
4: internal -> appfuse-basic-tapestry (creates a prototype of a web application based on Hibernate, Spring and Tapestry 4)
5: internal -> appfuse-core (creates a prototype of a jar application based on Hibernate and Spring and XFire)
6: internal -> appfuse-modular- jsf (create a modular application prototype based on Hibernate, Spring and JSF)
7: internal -> appfuse-modular-spring (create a modular application prototype based on Hibernate, Spring and Spring MVC)
8: internal -> appfuse-modular -struts (create a modular application prototype based on Hibernate, Spring and Struts 2)
9: internal -> appfuse-modular-tapestry (creates a modular application archetype based on Hibernate, Spring and Tapestry 4)
10: internal -> maven-archetype-j2ee-simple (a simple J2EE Java application)
11: internal -> maven-archetype-marmalade-mojo (a Maven plugin development project using marmalade)
12: internal -> maven-archetype-mojo (a Maven Java plugin development project)
13: internal -> maven-archetype-portlet ( a simple portlet application)
14: internal -> maven-archetype-profiles ()
15: internal -> maven-archetype-quickstart ()
16: internal -> maven-archetype-site-simple (simple site generation project)
17: internal -> maven-archetype-site (more complex website projects)
18: internal -> maven-archetype-webapp (a simple Java web application)
19: internal -> jini-service-archetype (Archetype for Jini service project creation)
20: internal -> softeu-archetype-seam (JSF+Facelets+Seam Archetype)
21: internal -> softeu-archetype-seam-simple (JSF+Facelets+Seam (no residue) archetype)
22: internal -> softeu-archetype -jsf (JSF+Facelets archetype)
23: internal -> jpa-maven-archetype (JPA application)
24: internal -> spring-osgi-bundle-archetype (Spring-OSGi archetype)
25: internal -> confluence-plugin- archetype (Atlassian aggregation plugin archetype)
26: internal -> jira-plugin-archetype (Atlassian JIRA plugin archetype)
27: internal -> maven-archetype-har (Hibernate archive)
28: internal -> maven-archetype-sar (JBoss service archive)
29: internal -> wicket-archetype-quickstart (a simple Apache Wicket project)
30: internal -> scala-archetype-simple (a simple scala project)
31: internal -> lift-archetype-blank (a blank/empty liftweb project)
32: internal -> lift-archetype-basic (a basic (liftweb) project)
33: internal -> cocoon-22-archetype-block-plain ( [ http://cocoapacorg2/maven-plugins/ ])
34: internal -> cocoon-22-archetype-block ([ http://cocoapacorg2/maven-plugins/ ])
35: internal -> cocoon-22-archetype- webapp ([ http://cocoapacorg2/maven-plugins/ ])
36: internal -> myfaces-archetype-helloworld (a simple archetype using MyFaces)
37: internal -> myfaces-archetype-helloworld-facelets (one using MyFaces and Facelets)
38: internal -> myfaces-archetype-trinidad (a simple archetype using MyFaces and Trinidad)
39: internal -> myfaces-archetype-jsfcomponents (a simple archetype using MyFaces to create custom JSF components)
40: internal -> gmaven-archetype-basic (Groovy basic archetype)
41: internal -> gmaven-archetype-mojo (Groovy mojo archetype)

So what number is entered will create the corresponding project skeleton.
If you need to create the simplest java project, you need to write the specific skeleton name, so you can use the number or the name of the skeleton in the step of selecting the skeleton. The way to choose a skeleton cannot create a simple java project, you have to use the name of the skeleton:

image

Created successfully:

image

image

The project code that comes with the project skeleton:

image

After creation, you can use mvn compile to compile, of course, other test commands can also be used:

image

8.mvn archetype:generate -DarchetypeArtifactId=maven-archetype-quickstart command: This command is used to select the skeleton for creating a common java project, which can skip the previous options and directly create the skeleton project.

image

Created successfully:

image

image

image

image

Select the skeleton of a common java project in Eclipse to create a project:

image

image

image

image

Created:

image

image

pom file:
open the pom configuration file in Eclipse, the first thing to enter is the interface for modifying project information, this interface can modify the information of the project

image

image

image

image

image

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327064523&siteId=291194637