Add a jar package to the maven project.

Source: Internet
Author: User

    Blog type: 

  • Spring3MVC tutorial
Many new users of mavenSpringXMLTomcatjunit 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 a jar package is very important!
Plugins: Add maven plug-in pages, such as tomcat-maven-plugin.
Reporting: Never used. Ignore ~
Dependency Hierarchy: Used to display the dependencies of the jar package. If it is okay, you can check the dependencies of the jar package.
Valid POM: Display the maven compilation path, plug-in and so on. You can also ignore it.
Pom. xml: Import the jar package information, 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 used for general spring3MVC development is enough. This article from: 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.