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 use of Maven

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

[1. Definition]

1. Maven Project object Model (POM), a project management tool software that manages project construction, reports and documents through a small piece of description information.

Maven not only features program building capabilities, but also provides advanced project management tools. Because Maven's default build rules are highly reusable, it is often possible to build simple projects with two or three lines of Maven build scripts. As a result of Maven's project-oriented approach, many Apache Jakarta projects are published using Maven, and the proportion of corporate projects adopting Maven continues to grow.

The word Maven, which comes from Yiddish (Jewish), which means the accumulation of knowledge, was originally used in the Jakata Turbine project to simplify the construction process. At that time, there were some projects (with their own Ant build files) with only slight differences, while the JAR files were maintained by CVS. So you want a standardized way to build a project, a clear way to define the composition of the project, an easy way to publish project information, and a simple way to share JARs among multiple projects.

2. Maven can manage the construction, reports and documentation of the project through a short description

3. Maven is a project management tool that includes:

(a) A project object model (Project Object Model)

(B) A set of standards, a project life cycle (Project Lifecycle)

(C) A dependency management system (Dependency Management System)

(d) the logic used to run the goal that defines the plug-in (plugin) goal in the lifecycle phase (phase).

4. Maven has a life cycle that is called when you run mvn install.

This command tells Maven to perform a series of orderly steps until you reach your specified life cycle.

[II. Common commands]

Mvn archetype:create creates a Maven project

Mvn compile compiled source code

Mvn test-compile compiles test code

Mvn test runs the test

A website where mvn site generates information about the project

Mvn clean clears the build results of the project

Mvn package package project generates jar/war file

Mvn install installs jar to local library

Upload mvn deploy to private server

Mvn eclipse:eclipse generates Eclipse project files

Mvn ieda:ieda generates IDEA project files

Mvn archetype:generate inversely generates the skeleton of the maven project

Mvn-Dtest package is only packaged and not tested

Mvn jar:jar only pack jar bags.

Mvn test- skipping compile-skipping test-compile only tests, neither compiles nor compiles tests

6. Create a Maven project: mvn archetype:generate

Compile source code: mvn compile

Publish Project: mvn deploy

Compile test source code: mvn test-compile

Run the unit test in the application: mvn test

The website that generates information about the project: mvn site

Clear the build result from the project directory: mvn clean

Jar:mvn package generated by the project

Install jar: mvn install in the local Repository

Generate eclipse project file: mvn eclipse:eclipse

Start the jetty service: mvnjetty:run

Start the tomcat service: mvntomcat:run

Clear the previous package and repackage it, skipping the test class: mvn clean package-Dmaven.test.skip=true:

[III. Use of Maven]

7. Configure Maven environment variables (abbreviated)

8. Verify the Maven configuration:

A) re-enter command line (DOS window) mode and enter echo% MAVEN_HOME%

B) enter mvn-version, which normally displays the version numbers of maven and jdk

[IV. Maven applications]

9. We will create a lot of projects in our work, and there will always be some common jar packages between projects. I used to copy all the jar packages in each project. This is obviously not good, the same file saved a lot of points on the hard disk, and jar packages are existing versions like commons-io-1.4.jar and commons-io-1.5.jar methods are not compatible. If all projects that reference this jar package need to be updated, they must be modified one by one.

10, maven warehouse is very good to solve these problems, it creates a native warehouse on each machine, all maven projects on this machine rely on the unified management of jar packages, and these jar packages are uniquely identified with "coordinates", so that all maven projects no longer need to copy jar packages to the lib directory as before.

[5. Idea integrated Maven]

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