In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the knowledge of "how to use maven in Java". 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!
What is Maven?
Maven is a cross-platform project management tool. As a successful open source project organized by Apache, it mainly serves the project creation based on Java platform, relies on management and project information management, and is an automated construction tool. Maven is the top-level project of Apache, interpreted as "expert, expert", it is a project management tool, maven itself is pure java development (Theresult is a tool that can now be used for building and managing any Java-basedproject), you can use maven to build and rely on the management of java projects.
II. The role of Maven
1. Manage jar packages
(1) add third-party jar packages (you do not need to download jar packages yourself)
(2) manage dependencies between jar packages (maven automatically associates and downloads all dependent jar packages)
two。 Split a project into several modules: with the help of Maven, you can split a project into multiple projects.
III. What Maven can do
1. Clean: removes the results of compilation in preparation for recompilation.
two。 Validate: verify that the project is correct and that all required information is available.
3. Cpmpile: java- > class
4. Test: test the key points in the project, or use the test code in the project to test the development code
5. Package: compress multiple files contained in the project into a single file for installation or deployment (java project into a jar package, web project into a war package, parent project-pom)
6. Verify: check the results of the integration test to ensure that the quality is up to standard
7. Installation (install): put the packaged packages in the local warehouse for use by other projects.
8. Deployment (deploy): put the packed package on the server, ready to run.
IV. Benefits of Maven
The benefits of Maven can be summed up in two points: dependency management and lifecycle.
1. Dependency management: unified management of third-party jar packages, defining the coordinates of jar packages through maven, and automatically downloading the project from the maven repository (reflecting the principle of code reuse)
two。 Life cycle: one-click build of life cycle, which provides a set of standards for project life cycle management. Developers and testers use maven to build projects. Life cycle management of the project: compile, test, package, deploy, run
Fifth, the warehouse classification and simple explanation of Maven
1. Local repository: equivalent to cache. The local repository is stored on a local disk containing frequently used jar packages.
two。 Remote warehouse: also known as private service. Almost every company will have its own private server. When the required jar package resources do not exist on the local disk, the private server will be requested to download the resources.
3. Central warehouse: remote warehouse, maintained by jar professional team.
6. Maven defines the description of each field of the jar package
GroupId: defines the name of the current Maven organization
ArtifactId: define the project module
Version: defines the version of the current project
Scope: scope of dependency
The dependency scope is shown in the following figure: (remind provided that when the project is actually running, there is a specific serclet-api in tomcat, so the dependency scope of servlet-api is specified as provided)
Seventh, Maven commonly used commands (life cycle)
Mvn clean command; clear the target directory
Mvn compile command; compile, generate target directory
Mvn test command; compile the test code with the core code
Mvn package command; compile the test code and core code and package the corresponding package types
Mvn install command; compile the test code and core code and package the corresponding package types and install the generated package to the local repository
Mvn deploy command; used to publish the project
This is the end of the content of "how to use maven in Java". 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.
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.