Use Maven to download Spring

Source: Internet
Author: User

Use Maven to download Spring

First, we recommend a Maven book "Maven Practice". Xu xiaobin is a great learning material for Maven. Since the Spring website was revised, many netizens complained that they could not directly download Spring from the website. Here we will teach you how to download Spring using Maven.

See Maven practice (translated by Xu xiaobin) for a complete hd pdf file.

Step 1:

For Maven installation, go to Maven.

Step 2:

Configure the environment variable, create the variable name MAVEN_HOME, and add % MAVEN_HOME % \ bin to the path variable.

Step 3:

Test whether the installation is successful. Open cmd and run mvn-version. The following output indicates that the installation is successful.

Apache Maven 3.2.3 (33f8c3e1027c3ddde99d3cdebad2656a31e8fdf4; 2014-08-12T04: 58: 10 + 08: 00) Maven home: D: \ Program Files (x86) \ maven3.2.3 \ bin \.. java version: 1.7.0 _ 05, vendor: Oracle configurationjava home: D: \ Program Files (x86) \ Java \ jdk1.7.0 _ 05 \ jreDefault locale: zh_CN, platform encoding: GBKOS name: "windows nt", version: "6.2", arch: "x86", family: "windows"

Step 4:

Modify the location of the local repository. After Maven is installed successfully, the default location of the local repository is ~ /. M2/repository directory ("~" Indicates the user's directory. For example, in windows, C: \ Documents and Settings \ [your user name] \. This is definitely not what we need, so we need to manually configure the location of the local repository, enter the D: \ Program Files (x86) \ maven3.2.3 \ conf directory, find settings. open the xml file and enable this configuration item <localRepository> D:/Program Files (x86)/maven3.2.3/repository </localRepository>. The path inside is the path of my Maven local repository.

Step 5:

Maven configuration,

, Change the path in User Settings to the settings. xml file path after you enable the local repository.

Step 6:

Create a Maven project in eclipse and visit the official Spring website.

This figure shows the information provided on the spring official website. copy and paste the information directly to the pom. xml file. Right-click a project and refresh it. Then we can see that the Spring jar package is included in MavenDependencies. My pom. xml file is for your reference:

<Project xmlns = "http://maven.apache.org/POM/4.0.0" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi: schemaLocation = "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<ModelVersion> 4.0.0 </modelVersion>

<GroupId> MavenProject </groupId>
<ArtifactId> first </artifactId>
<Version> 0.0.1-SNAPSHOT </version>
<Packaging> jar </packaging>

<Name> first </name>
<Url> http://maven.apache.org </url>
<Properties>
<Project. build. sourceEncoding> UTF-8 </project. build. sourceEncoding>
</Properties>

<Dependencies>
<Dependency>
<GroupId> junit </groupId>
<ArtifactId> junit </artifactId>
<Version> 4.12 </version>
<Scope> test </scope>
</Dependency>
<Dependency>
<GroupId> org. apache. logging. log4j </groupId>
<ArtifactId> log4j-api </artifactId>
<Version> 2.1 </version>
<Scope> test </scope>
</Dependency>
<Dependency>
<GroupId> org. springframework </groupId>
<ArtifactId> spring-context </artifactId>
<Version> 4.1.3.RELEASE </version>
</Dependency>
</Dependencies>
</Project>
 

Step 7:
Provides a Maven repository URL. For example

<Dependency> <groupId> org. hibernate </groupId> <artifactId> hibernate-core </artifactId> <version> 4.3.7.Final </version> </dependency> <groupId> org. hibernate </groupId> <artifactId> hibernate-entitymanager </artifactId> <version> 4.3.7.Final </version> </dependency> <groupId> org. hibernate </groupId> <artifactId> hibernate-annotations </artifactId> <version> 3.5.6-Final </version> </dependency>

Maven 3.1.0 release, Project Build Tool

Install Maven in Linux

Maven3.0 configuration and simple use

Set up sun-jdk and Maven2 in Ubuntu

Get started with Maven

Maven details: click here
Maven: click here

This article permanently updates the link address:

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.