Maven Project introduces JAR package

Source: Internet
Author: User

The MAVEN project introduces the method of jar package, hoping to help the friends who are in need

Law I. Manual import: Project Right-->build path->configure Build path-> Select libraries-> Click Add External jars-> Select the JAR package import that has been prepared beforehand.

Method Two. Add through the dependencies tag of the Pom.xml file

Open the Pom.xml file for the MAVEN project. We can see 7 tabs below.

Overview: Shows some basic information about the MAVEN project
Dependencies: Adding a Jar package page
Plugins: Add a Maven plugin page. such as Tomcat-maven-plugin, etc.
Reporting: Never used, ignored
Dependency Hierarchy: Used to display the dependencies of the jar package. You can look at the dependencies of the jar package when it's okay.
effective POM: Displays the compilation path of Maven, plugin and the like. You can ignore
pom.xml: Import the jar package information, in which you can modify


Now we add the jar package.
Click the Dependencies tab.
Click the Add button in the dependencies
Enter the name of the jar package that we want to add. It will appear as shown in.
It will list all versions of the jar package for the corresponding name.


Let's add the Spring-context package first.


Look at the location of the red Line. Version is the build number of this jar package. We can modify the value of this version by
To upgrade the JAR package.
Type represents the types of dependent packages.
The scope represents the cycle of the dependency package.
After saving. If you are installing MAVEN for the first time, there may be a long time for the jar pack download process.
As long as the jar package is downloaded locally for the first time, it will not need to be downloaded.
The MAVEN default jar package is in the C-drive user-->%user%-->.m2
After Maven downloads the jar package. We'll open up the Maven Dependencies in the project.
You will find 8 more jar packages.


But we only added a Spring-context package except for our own JUnit package.
Why do you have to make more of these bags?
Many of these packages are actually packages that have dependencies on Spring-context packages.
MAVEN will download and add all the dependencies of the jar package. This avoids the problem of missing jar packages.
In fact, we just need to add
Spring-webmvc
Spring-orm
will be able to get 14 jar packages related to spring.
And these 14 jar packages are used as a general SPRING3MVC development enough.

Method Three. Directly modify the dependencies of the Pom.xml file

Open the Pom.xml file, select Pom.xml, add dependencies

, annotated GroupID, Artifactid, and version, MAVEN will automatically add the appropriate package when updating the project

Follow up update ing ... 

Resources:

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

Maven Project introduces JAR package

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.