Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Introduction and common commands of maven

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "introduction to maven and common commands". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Introduction and advantages of 1.maven

Maven is a project build and management tool that provides methods to help manage builds, documentation, reports, dependencies, scms, release, and distribution. You can easily compile code, manage dependencies, manage binary libraries, and so on. The advantage of maven is that it can standardize, automate, efficiently and expand the project process. Using maven itself and its plug-ins, it can also obtain code inspection reports, unit test coverage, continuous integration and so on.

Maven advantages:

1. Project automation compilation and deployment

two。 Dependency Management of Project jar package

3. Plug-in management of the project

2.maven installation

2.1. Download and extract Maven3

2.2. Extract maven, rename the folder to maven-3.3.1, and set the maven environment variable

Installation directory: d:\ tool\

Environment system variable: MAVEN_HOME= D:\ tool\ maven-3.3.1 PATH=% MAVEN_HOME%/bin

2.3. Installation is complete, check to see if the installation is successful or not mvn-v

3.maven system configuration

3.1 profile

File path:% MAVEN_HOME%/conf/setting.xml

Configure the local repository: localRepository node, D:/dev/maven3Repository

Central repository image: mirrors node, which can be configured with its own central repository. If it is not configured, the maven dependency plug-in will be downloaded from the official website by default for the first time.

Setting.xml profile:

Java code

1. 4. 5. D:/dev/maven3Repository 6. 7. 14. 15.

4.maven jvm configuration

Find the file mvn.bat in the% M2roomHOME%\ bin directory, and configure the maven jvm startup parameters under MAVEN_OPTS:

Set MAVEN_OPTS=-Xmx1024m-Xms1024m-Xmn512m-Xss512k-XX:+DisableExplicitGC-XX:MaxPermSize=256m

5.maven project convention

Conventions are greater than configuration: project conventions are mainly about standardizing developer programming, unifying project style, and simplifying operation and code volume.

The same is true for maven, as shown in the following figure:

Directory structure, where pom.xml is in the root directory of its project

6.maven common commands

The project skeleton is to create the project directory structure and resource files according to the rules of the maven project convention.

1)。 Quick create Project commands:

Java code

Mvn archetype:generate-DarchetypeCatalog=internal-DgroupId= project team-DartifactId= project name / module name-Dversion=1.0-SNAPSHOT-Dpackage=com..

2)。 Follow the template wizard to create:

Html code

Generate the java project: mvn archetype:generate-DarchetypeCatalog=internal-DarchetypeArtifactId=maven-archetype-quickstart

Generate the web project: mvn archetype:generate-DarchetypeCatalog=internal-DarchetypeArtifactId=maven-archetype-webapp

When prompted, the wizard fills in groupId (project team name) artifactId (project unique identifier) version (version number), and these three attributes are defined as the warehouse coordinates of maven:

6.2 Common commands:

Java code

1. Mvn archetype:generate build project 2. Mvn clean project cleanup 3. Compilation of mvn compile project source code 4. Compilation of mvn test project unit tests 5. Mvn package project packaging 6. Mvn install release project submitted to local warehouse 7. Mvn deploy release project to 8. Mvn jetty: Run: start jetty container 9. Mvn eclipse:clean: clear some system settings for eclipse 10. Mvn eclipse:eclipse: generate Eclipse project files

Practical command

Java code

1. Mvn dependency:tree View dependency Tree 2. Mvn assembly:assembly needs to be equipped with an assembly plug-in, which can be used to package the specified file tar.gz,zip package 3. Specify maven parameters: 4.-DskipTests=true default does not go unit test 5.-P local select resource file type local, need to open resource configuration in pom "maven introduction and common commands" content is introduced here, thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report