Pom File Usage

Source: Internet
Author: User

Many new users do not know how to add jar packages to Maven projects.
I downloaded a demo before using maven. It is a Maven project.
I wrote it one by one based on his Pom. xml file !!!
What many take for granted is a difficult threshold for beginners.
Therefore, write down how to add a jar package to the maven project.

According
Create a standard Maven web project with m2eclipse. This blog creates a Maven-based Web project.

How can we add a jar package after it is created?

Click the Pom. xml file. We can see 7 labels below.



They are
Overview: displays some basic information about the maven project.
Dependencies: the page for adding jar packages. It is very important!
Plugins: page for adding Maven plug-ins, such as Tomcat-Maven-plugin.
Reporting: never used. Ignore it ~
Dependency hierarchy: used to display the dependencies of the jar package. If nothing happens, you can check the dependencies of the jar package.
Tive pom: displays the maven compilation path, such as plugin. You can also ignore it.
Pom. xml: information about the imported jar package, which can be modified. Important


This is the basic introduction to Pom. xml.
Now we add the jar package.
Click the dependencies tab.
Click Add in dependencies.
Enter the name of the jar package we want to add.
It will list all the jar packages of the corresponding name.

 

Add the spring-context package first.



Note that the location of the Red Line. version is the version number of the jar package. You can modify the value of this version.
Upgrade the jar package.

Type indicates the type of the dependent package.
Scope indicates the cycle of the dependent package.
We will ignore these questions for the moment.
After saving. If Maven is installed for the first time, there may be a long jar package download process.
As long as the jar package is downloaded locally for the first time, you do not need to download it.
The default jar package of Maven is in drive c --> User --> % USER % -->. m2

After Maven downloads the jar package, click Maven dependencies in the project.
Eight jar packages are added, as shown in figure

 

However, apart from the built-in JUnit package, we only added a spring-context package.
Why are these extra packages?

Many of these packages are actually dependent on the spring-context package.
Maven will download all the dependencies with the added jar package. This avoids the problem of missing jar packages.


So in fact, we only need to add
Spring-webmvc
Spring-ORM
You can get 14 jar packages related to spring.

The 14 jar packages are sufficient for general spring3mvc development.


Reprinted: http://liukai.iteye.com/blog/973120


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.