您的位置:首页 > 编程语言 > Java开发

spring4.0源码下载

2015-05-29 22:41 501 查看
1、下载工具

下载最新的eclipse,因为最新版本的eclipse,自带git插件。已经有eclipse或者git的跳过此步骤。

http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/lunasr2


2、下载源码

打开eclipse,选择Windows——Preferences——Show View,找到Git Repositories,选择Clone 一个远程repositories。 在url输入框中输入如下地址,并设置一个本地地址,用于存放下载到得代码。

git://github.com/SpringSource/Spring-framework.git


这个过程比较慢,等下载完成后,在本地已经有了如下文件夹。



















3、说明

spring不但将代码放在了git上,项目构建也改为由Gradle构建。所以,想把下载到得spring源码,转换成eclipse项目,还需要靠Gradle。幸运的是,我们刚才下载的文件中,已经包含了Gradle。

###NOTE###spring4.0源码构建项目,需要用到JDK1.8.0+,否则会失败,出现莫名奇妙的错误。

在刚才下载的文件中,有一个README.md文件,打开后,简单阅读。找到如下文字

## Building from Source

The Spring Framework uses a [Gradle][]-based build system. In the instructions

below, [`./gradlew`][] is invoked from the root of the source tree and serves as

a cross-platform, self-contained bootstrap mechanism for the build.

### Prerequisites

[Git][] and [OpenJDK 8 early access build 100 or later][JDK8 build]

Be sure that your `JAVA_HOME` environment variable points to the `jdk1.8.0` folder

extracted from the JDK download.

### Check out sources

`git clone git@github.com:spring-projects/spring-framework.git`

### Import sources into your IDE

Run `./import-into-eclipse.sh` or read `import-into-idea.md` as appropriate.

> **Note:** Per the prerequisites above, ensure that you have JDK 8 configured properly in your IDE.

### Install all spring-\* jars into your local Maven cache

`./gradlew install`

### Compile and test; build all jars, distribution zips, and docs

`./gradlew build`

... and discover more commands with `./gradlew tasks`. See also the [Gradle

build and release FAQ][].

<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">下载jdk1.8,注意下载和自己操作系统匹配的版本</span>
<span style="font-family: Arial, Helvetica, sans-serif;">http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html</span>


下载安装后,记得添加环境变量

4、构建项目

双击 import-into-eclipse.bat ,开始构建项目。





###NOTE### 可能由于网络原因,导致下载jar包的时候,会卡住或者中断。这个时候重新双击 import-into-eclipse.bat ,如果再卡住就关掉再点。直到提示BUILD SUCCESS。然后按几次回车后,完成。

5、项目导入eclipse

把spring的项目依次导入eclipse中。如下图



有报错,提示

GroovyDynamicElementReader cannot be resolved to a type

说明少groovy的jar包。

安装一个eclipse的groovy插件

在eclipse的 Help -> Install New Software 中,添加groovy的下载连接:
http://dist.springsource.org/milestone/GRECLIPSE/e4.4/
然后全选后,开始下载,下载完后,重启eclipse,然后clean一下项目就搞定了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: