Spring源码(一)

304 阅读1分钟

开始记录下阅读和理解Spring源码的历程,也将遇到的一些问题记录下来。

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

fork一份自己的库,以便将自己的注释和测试提交,方便后续理解。

  • 导入至idea

根据官方文档import-into-idea.md :

Within your locally cloned spring-framework working directory:

  1. Precompile spring-oxm with ./gradlew :spring-oxm:compileTestJava
  2. Import into IntelliJ (File -> New -> Project from Existing Sources -> Navigate to directory -> Select build.gradle)
  3. When prompted exclude the spring-aspects module (or after the import via File-> Project Structure -> Modules)
  4. Code away

因gradle默认配置好像不正确,导入后发现各模块无法识别,需要修改配置,我将settings.gradle 文件中的配置进行了更改,插件库中增加了maven库,因使用个人私服,没有测试阿里库是否正常使用,理论上应该也没问题,修改后如下所示:

pluginManagement {
   repositories {
      maven {
         url "http://nexus.xxxxx.com/repository/maven-public/"
      }
      jcenter()
      gradlePluginPortal()
   }
}

点击gradle刷新按钮后,等待一段时间,就成功了,后面就专心开始搞了~~