In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what are the functions of Maven". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the role of Maven"?
The first role of maven: dependency management: the process of managing jar packages in a project by maven. In the traditional project, we put the jar package directly in the project, the real jar package of the maven factory is placed in the warehouse, and only the coordinates of the jar package are placed in the project.
Types of warehouses: local warehouse, remote warehouse, intermediary warehouse
Relationship between warehouses: when we start a maven factory, the maven project uses the coordinates of the jar package in the pom file to go to the local warehouse to find the corresponding jar package. By default, if there is no corresponding jar package locally, the maven project will automatically download the jar package to the local warehouse from the central warehouse. In the company, if there is no corresponding jar package locally, the jar package will be downloaded from the private server (the company needs to create it). If the private server does not have the jar package, it can be downloaded from the central warehouse or uploaded locally.
The second function of maven: one-click construction: maven itself integrates the tomcat plug-in, which can compile, test, package, install and release the project, and distribute the common commands corresponding to maven.
Maven common command: clean,compile,test,package,install,deploy
Maven has three lifecycles: cleanup lifecycle, default lifecycle, and site lifecycle.
Clean up the lifecycle: Clean Lifecycle does some cleanup before actually building
Default lifecycle: core parts of Default Lifecycle build, editing, testing, packaging, deployment, etc.
Site life cycle: Site Lifecycle generates project reports, sites, publishing sites
Note: the three life cycles are independent of each other.
Maven resolves jar package conflicts
Method 1: the first declaration priority principle: which jar package and other coordinates in the upper position, the jar package is declared first. The dependent packages under the coordinates of the jar package declared first can be given priority to enter the project.
Method 2: direct dependency: the jar package imported directly into the project is the direct dependency package of the project. Pass-through dependency: the jar package is not directly imported into the project and can be passed to the project through the jar package that the project directly depends on. Principle of giving priority to those who are close to the path: if the direct dependent path is closer than the transitive dependent path, then the final jar package entered by the project will be the path near direct dependent jar package.
Method 3: direct exclusion: pass-through dependency jar packages can be eliminated through tags
Split and aggregation of projects:
Split idea: maven divides a complete project into different independent modules, these modules have their own independent coordinates, where the need for the module, you can directly refer to the coordinates of the module.
Collective idea: assemble the fragmented modules together to write a complete project.
Solve the problem that the code is reusable and easy to maintain
The difference between project and module:
1, the project is not equal to the complete project, the module is not equal to the complete project, a complete project looks at the code, the code is complete, it can be said that this is a complete project and this project is not related to the project and the module.
2. The project can only use its own internal resources. The project is inherently independent and can be associated with other projects or modules. Modules are not inherently independent, and modules are born to belong to the parent project. once the module is created, all the resources of the parent project can be used.
3. Father-son project, the child module is born to integrate the parent project, and all the resources of the parent project can be used. There is no natural relationship between the sub-modules.
4. The parent-son project does not need to establish a relationship. The inheritance relationship is innate and does not need to be established manually. The reference to the peer-to-peer relationship is called dependency, which needs to be established.
Start mode of father-son project:
First: direct run of parent project
Second: install the parent project first, before starting the following module
Third: add local tomcat startup, add project startup
Private server:
1. Download and install the private server installation package Nexus https://www.sonatype.com/oss-thank-you-win64.zip
2. Configure Nexus. Configure Nexus port, IP, and context path in nexus-default.properties under etc directory.
3. Start the service
Hosted: hosting warehouse (stores the jar package developed by our company (official version test version third party: copyright problem-Oracle))
Proxy: agent repository (agent central repository, test version of jar package under apache)
Group: group repository (connect group repository in the future). Contains Hosted: host warehouse, proxy: agent warehouse)
Virtual: virtual warehouse (abandoned warehouse)
Upload Jar package to private server
1. Configure the user name and password for conf/setting.xml under the maven directory.
Releases admin admin123 snapshots admin admin123
2. Configure the upload path of jar package in pom.xml
Releases http://localhost:8081/nexus/repository/maven-releases snapshots http://localhost:8081/nexus/repository/maven-snapshots
Download Jar package from private server
1. Configure the conf/setting.xml template in the maven directory
Dev nexus http://localhost:8081/nexus/repository/maven-public true true public Public Repositories http://localhost:8081/nexus/repository/maven-public
2. Activate the template in conf/setting.xml
Dev thank you for your reading, the above is "what is the role of Maven" content, after the study of this article, I believe you have a deeper understanding of the role of Maven, the specific use of the need for practice to verify. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.