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

Instructions for quick use of maven

2025-03-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

1. Download maven: https://maven.apache.org/download.cgi

Configure the environment variable: M2_HOME:D:\ apache-maven-3.5.4: path:%M2_HOME%\ bin; test maven:cmd mvn-v

2. The value of groupId is the package name of the project

The value of artifactId is based on the module name, version version, for example: the directory structure of com.maven.demo maven01-model 0.0.1SNAPSHOT maven project src-main-java-package-test-java -package resources mvn compile mvn test mvn package

3. Maven common build commands

Mvn-v View maven version compile compile test test package package clean delete target install install jar package to the local repository (first find pom.xml dependency, looking for local library, and finally find online central library) maven automatically build directory skeleton first way mvn archetype:generate second way mvn archetype:generate-DgroupId= organization name Reverse of company web address + project name-DartifactId= project name-module name-package maven coordinates and warehouse basic coordinates that exist in Dversion=1.0.0SNAPSHOT-Dpackage= code: component Com.maven.demo maven01-model 0.0.1SNAPSHOT Repository: local Warehouse remote Warehouse (maven-model-bulider) Image Warehouse\ apache-maven-3.5.4\ conf\ settings.xml (152Lines) maven.net.cn central Central mirror in china http://maven.net.cn/content/groups/public changes the warehouse location (default path: C:\ Users\ CHUAN\ .m2)\ apache-maven-3.5.4\ conf\ settings.xml (53 lines) eclipe installs the maven plug-in and creates the maven project Preferences-Maven-Installations Add maven directory-User Settings add maven setting.xml (.\ apache-maven-3.5.4\ conf\ setting.xml) maven life cycle and plug-in complete project artifact process includes: cleanup, Compile, test, package, integrate test, verify, Deploy maven lifecycle clean cleanup project work before pre-clean perform cleanup clean clean up all files generated by the last build post-clean perform cleanup files default build project (core) compile test package install site build project site pre-site Work to be completed before building the project site site build project site documentation post-site work to be completed after building the project site site-deploy publish the generated site to the server maven life cycle clean, Pom.xml parsing 4.0.0 in compile, test, package and installmaven specifies the version coordinate information organization name of the current pom Reverse of the company web address + project name identification of the main project-module name module identification of the current project version number packaging method project description project description project developer license organization important: dependency list Test dependency range true/ default false setting depends on whether it is optional If the false subproject is inherited by default, if it is a true subproject, the pass-through list of dependency exclusion must be displayed to introduce the dependency. Dependency management contains multiple dependencies Will not be run. Mainly define the list of plug-ins used by the parent module for the child module to inherit Used for submodule inheritance to parent module aggregation multiple module maven dependency scope three classpath: compile test test run compile: default scope Compile test runs all valid provided: compile and test valid runtime: valid at run time test: only test valid typical application junit system: when compiling and testing valid associated with native system, poor portability import: scope of import, it is only used in dependencyManagerment Indicates that the configuration http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html maven that imports dependecy from other pom is an a-pom.xml b-pom.xml c-pom.xml that depends on the delivery feature. If b integrates amemc, it will automatically integrate a. If you create a maven project, jre system library displays jre5, but inside jre is 1.8 modify setting.xml (188 lines) jdk-1.8 true 1.8 1.8 1 .8 1.8 maven dependency conflicts 1. Short circuit priority A-> B-> C-> X (jar) A-> D-> X (jar) priority parsing for example: a depends on 2.4jar B depends on An and 2.0jar C depends on B so C depends on 2.0jar 2, declare first if the path length is the same Then who declares first? First parse who for example: a depends on 2.4jar B depends on pom An in 2.0jar C before B, so C depends on 2.4jar Maven aggregation and inheritance maven aggregation: the pom file of the parent module modifies the pom child module project name one child module project name two maven relay Inherit: if each module, that is, the pom in each small module has a duplicate jar such as junit, then inheritance can be used. Create a parent project, change the tag element value to pom, and then add a tag to put the dependency into it. The version number, which can be indicated by reference, needs to be labeled. Child classes refer to parent pom.xml coordinates with tags, for example: pom.xml in the new parent class is as follows: pom 3.8.1 junit junit ${junitversion} test subclass pom.xml The coordinates of the parent pom.xml junit junit use maven to build the web project add the coordinates of the java servlet api scope manually create the maven skeleton file for provide check the java build path outfolder to / target/classes/ directory project convert to the web project Right-click attribute. Project facets check publish right-click attribute for Dynamic. Deployment assembly removes all test from pom.xml and uses the packaging command to type into a war package and add jetty maven plug-ins to pom.xml package run. Summary:

Maven download and environment building

Maven directory skeleton description

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: 274

*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