Spring源码阅读1:环境搭建

前言:

Spring是一款优秀的开源框架,使用非常广泛,研读Spring源码就像是开采一个大金矿,深度开采会有取之不尽的知识财富。


Spring是什么?

The term "Spring" means different things in different contexts. It can be used to refer to the Spring Framework project itself, which is where it all started. Over time, other Spring projects have been built on top of the Spring Framework. Most often, when people say "Spring", they mean the entire family of projects. This reference documentation focuses on the foundation: the Spring Framework itself.

The Spring Framework is divided into modules. Applications can choose which modules they need. At the heart are the modules of the core container, including a configuration model and a dependency injection mechanism. Beyond that, the Spring Framework provides foundational support for different application architectures, including messaging, transactional data and persistence, and web. It also includes the Servlet-based Spring MVC web framework and, in parallel, the Spring WebFlux reactive web framework.

--引自Github Spring-frame Overview

环境搭建:

1.下载源码:

Code放在Github上,首先访问github官网https://github.com/,在搜索框中输入Spring。

Spring源码阅读1:环境搭建

在左侧的Languages选择Java,如下

Spring源码阅读1:环境搭建

找到spring-framework,点进去。

Spring源码阅读1:环境搭建

在弹出的页面中点击"Clone or download",

Spring源码阅读1:环境搭建


这里我们选择通过Git把源代码clone过来.

从git官网https://www.git-scm.com/download/根据操作系统版本下载对应的git版本。我下载的window版本,双击安装即可。

Spring源码阅读1:环境搭建

安装好后,选择或者新建一个存储源码的文件夹,在文件夹内右键选择"Git Bash Here".

Spring源码阅读1:环境搭建

git clone https://github.com/spring-projects/spring-framework.git

Spring源码阅读1:环境搭建

代码clone过来后,目录结构如下

Spring源码阅读1:环境搭建

2.导入Eclipse

前提:

To build you will need Git and JDK 8 update 20 or later. Be sure that your JAVA_HOME environment variable points to the jdk1.8.0 folder extracted from the JDK download.

安装Gradle:

导入gradle项目,可以参考博客 eclipse安装Gradle插件https://blog.****.net/wzj0808/article/details/52267852

导入:

安装好后,Eclipse项目空白处,右键选择"Import"

Spring源码阅读1:环境搭建

在弹出的选项中选择Gradle Project

Spring源码阅读1:环境搭建

导入后,如下

Spring源码阅读1:环境搭建

可以发现项目前面有个感叹号,这是因为没有引用到JDK或者JDK版本不对,右键选择"Build Path",选择正确的JDK路径即可。

Spring源码阅读1:环境搭建

Spring源码阅读1:环境搭建