Common commands of maven foundation (1)

1: Introduction to Maven:

Maven is a project management tool that includes a project object model (Project Object Model), a set of standard collections, a project life cycle (Project Lifecycle), a dependency management system (Dependency Management System), and used to define the life cycle The logic of the Plugin goal (gole) in Phases. When using Maven, describe your project with a well-defined project object model.

Role: A tool to help us build projects, publish projects, and manage dependencies.

pom.xml tag introduction:

1.groupId: The unique identifier of the project or organization

2.artifactId: project name

3.version: version number

groupId/artifactId/version can identify a specific project, and these three tags need to be declared when relying on it (subprojects can not declare version, and the version in the parent pom.xml will be automatically)

4.packaging: packaging mechanism, such as: pom, jar, ejb, war, ear, rar, par, maven-plugin

5.name: User describes the name of the item

6. url: The website of the development team

7.scm: declare version control tool information

<scm>

<connection>scm:svn:http://10.10.5.43/SC/SPROC4GD/00_code/sproc4gd</connection>

<developerConnection>scm:svn:http://10.10.5.43/SC/SPROC4GD/00_code/sproc4gd</developerConnection>

<tag>HEAD</tag>

<url>http://10.10.5.43/SC/SPROC4GD/00_code/sproc4gd</url>

</scm>

8.dependencies: declare the public dependency information of the project, which contains a set of dependencies

9.parent: declare the parent project information. When the project is built, if no dependencies are found, it will go to the parent pom.xml to find it. It is only required in the subproject pom.xml.

10.dependencyManagement Dependency management, for optional dependencies, this label contains the dependencies label, which should be marked with the version number as mentioned above. However, the dependencies declared under this tag are for use by subprojects. When a dependency is declared in a subproject without a version declaration, it will go to the parent pom.xml to find out whether there is a declaration under dependencyManagement.

11.modules: Templates to be built, searched from the current directory by default

12.properties: Define some constants for pom, which can be directly referenced elsewhere in pom.

Defined by:

<properties>

   <project.version>1.0.0</sproc4gd.release.version>

</properties>

How to use:

${project.version}

13.build Declare the target of the build, the build directory, the name after the build, etc., is done using a series of plugins.

14.reporting: Mainly declare the reports that need to be produced, such as javadoc, unit test reports, etc., are also done using a series of plugins

15.organization: project organization, optional

16. developer Publisher

17.repositories maven warehouse

18.profiles: allows us to define a series of configuration information, and then specify its activation conditions for activation

 

Second, mvn common commands

1. Create a common java project for Maven:

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

2. Create a Maven Web project:

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

-DarchetypeArtifactId=maven -archetype -webapp

3. Compile the source code, the code in the test directory will not be compiled, and the relevant dependency packages will be downloaded when running for the first time:

mvn compile

4. Compile the test code:

mvn test -compile

5. Run the test:

mvn test

6. Packaging:

mvn package

7. Install the jar in the local repository:

mvn install

8. Clear the resulting project:

mvn clean

9. Production eclipse project:

mvn eclipse:eclipse 清除mvn eclipse:clean

10. Production items:

mvn archetype:generate -DgroupId=com.study.simple  -DartifactId=simple-web -DarchetypeArtifactId=

maven-archetype-webapp 

 

Three, mvn common parameters

1.mvn -e displays detailed errors

2.mvn -U Force update of snapshot type plugins or dependent libraries (otherwise maven will only update snapshot dependencies once a day)

3.mvn -o run offline mode, do not update dependencies online

4.mvn -N only executes the command in the current project module, closes the reactor

5.mvn -pl module_name executes the command on the specified module

6.mvn -ff In the process of recursively executing the command, exit directly once an error occurs

7.mvn -Dxxx=yyy specifies java global properties

8.mvn -Pxxx reference profile xxx

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326354111&siteId=291194637