---
title: "Could not find artifact org.springframework:spring-core:jar:3.1.0.M2 in central "
author: "蒋兆欣"
date: "2011-09-12T13:08:28Z"
tags: []
categories: ["Web前端"]
slug: "could-not-find-artifact-org-springframework-spring-core-jar-3-1-0-m2-in-central"
draft: false
lastmod: "2011-09-12T13:08:28Z"
id: 1170347
url: "https://2o12.iteye.com/blog/1170347"
---

在pom.xml中配置了spring的相关依赖包 ,

```
   </dependency>
.....
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-core</artifactId>
			<version>${org.springframework.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-aop</artifactId>
			<version>${org.springframework.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
			<version>${org.springframework.version}</version>
		</dependency>
.....
  </dependencies>
```

 

settings.xml中也指定了本地仓库路径（因为这些构建已经存在于）

```
<localRepository>D:\workapp\apache-maven-3.0.3\repository</localRepository>
```

运行命令 mvn clean test

报错如下 ： \[ERROR] Failed to execute goal on project com.iteye.zxJiang.spring.beginner: Could not resolve dependencies for project com.iteye.zxJiang.spring.beginner:com.iteye.zxJiang.spring.beginner:war:1.0.0-SNAPSHOT: The following artifacts could not be resolved: org.springframework:spring-core:jar:3.1.0.M2, org.springframework:spring-expression:jar:3.1.0.M2, org.springframework:spring-web:jar:3.1.0.M2, org.springframework:spring-webmvc:jar:3.1.0.M2: Could not find artifact org.springframework:spring-core:jar:3.1.0.M2 in central (http://repo1.maven.org/maven2) -&gt; \[Help 1]

 

分析 ：从默认的仓库中心下载不了这些jar包 ? 但是我本地仓库明明有的啊 ? 难道它不是先检查本地仓库，找不到的话再去远程的仓库找吗? 我认为可能是它需要先去远程仓库检查jar包是否存在或者jar的更新的情况吧，只是猜测，不想深入了解！

 

解决办法 ：在pom.xml指定一个repository(仓库)

```
   <repositories>
	   <repository>
	        <id>org.springframework.maven.milestone</id>
	        <name>spring-framework-repo</name>
	        <url>http://maven.springframework.org/milestone</url>
	        <layout>default</layout>
	        <snapshots>
	            <enabled>false</enabled>
	        </snapshots>
	        <releases>
	            <enabled>true</enabled>
	        </releases>
	    </repository>
    </repositories>
```