songshuiyang / spring-framework-4.3.10.RELEASE

Spring 4.3.10版本源码,用于学习Spring源码添加中文注释及本地调试代码

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

为什么要阅读源码

  • 站在巨人的肩膀上看世界,看看大佬们是怎么写代码的,一些写代码的模式或者技巧是否可以运用到实际项目中
  • 许多东西不能只停留在使用层面,更要知其所以然,提高自己知识的深度
  • 可以融会贯通,看得越多,知识的互通性的愈发明显,比如一些设计**,设计模式这些在其他框架也是大量的运用

下载并导入源码

  • 源码地址 https://github.com/spring-projects/spring-framework 选择合适的版本,此版本是4.3.10.RELEASE版本

  • 配置gradle环境

  • 详情可见源码父目录下的import-into-idea.md说明文档来将源码导入到IDEA环境中,执行import-into-eclipse.bat脚本将源码可导入至eclipse环境中

  • 导入到IDEA环境中操作步骤

    • 进入 spring-framework 文件夹下,打开cmd,输入 gradlew :spring-oxm:compileTestJavaspring-oxm 应该预编译,因为它使用重新打包的依赖项,被其他包依赖

    • 排除 spring-aspects 模块 1、Exclude(Go to File->Project Structure->Modules) 2、右键unmark as sources rootidea不认为此目录是源代码文件夹,不然此模块不然在本地编译不过

    • 执行gradlew.bat

问题记录

  • 执行gradle命令报错

    • 尝试更换版本,多下几个版本的gradle
  • 执行gradle命令报错误: 找不到或无法加载主类 org.gradle.wrapper.GradleWrapperMain

    • 检查源码目录下是否有 gradle/wrapper/gradle-wrapper.jar,如果没有从其他项目中copy一份
  • 执行gradle命令报taskdef class jdiff.JDiffAntTask cannot be found

    • 注释该文件的下面代码
    ant.taskdef(
            name: "jdiff",
            classname: "jdiff.JDiffAntTask",
            classpath: "${jdiffHome}/antjdiff.jar")
  • 有些类GroovyBeanDefinitionReader GroovyBeanDefinitionReader编译报错说是找不到

    • 找到对应GroovyBeanDefinitionReader的模块是spring-beans-groovy
    • 然后在找到build.gradle文件将compile(project(":spring-beans-groovy"))依赖添加到对于报错的模块中
      project("spring-context") {
          description = "Spring Context"
      
          apply plugin: "groovy"
      
          dependencies {
              compile(project(":spring-aop"))
              compile(project(":spring-beans"))
              compile(project(":spring-beans-groovy"))
  • 设置测试类不编译,修改文件build.gradle,不然每次点击方法在哪里调用都会冒出一堆测试类供你选择

sourceSets {
    test {
        java.srcDirs = ['src/排除test目录']
    }
}

test {
    systemProperty("java.awt.headless", "true")
    systemProperty("testGroups", project.properties.get("testGroups"))
    scanForTestClasses = false
    include(["**/*Tests.class", "**/*Test.class"])
    // Since we set scanForTestClasses to false, we need to filter out inner
    // classes with the "$" pattern; otherwise, using -Dtest.single=MyTests to
    // run MyTests by itself will fail if MyTests contains any inner classes.
    exclude '*'
}

Spring Framework

The Spring Framework provides a comprehensive programming and configuration model for modern Java-based enterprise applications -- on any kind of deployment platform. A key element of Spring is infrastructural support at the application level: Spring focuses on the "plumbing" of enterprise applications so that teams can focus on application-level business logic, without unnecessary ties to specific deployment environments.

The framework also serves as the foundation for Spring Integration, Spring Batch and the rest of the Spring family of projects. Browse the repositories under the Spring organization on GitHub for a full list.

Code of Conduct

This project adheres to the Contributor Covenant code of conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to spring-code-of-conduct@pivotal.io.

Downloading Artifacts

See downloading Spring artifacts for Maven repository information. Unable to use Maven or other transitive dependency management tools? See building a distribution with dependencies.

Documentation

See the current Javadoc and reference docs.

Getting Support

Check out the spring tags on Stack Overflow. Commercial support is available too.

Issue Tracking

Report issues via the Spring Framework JIRA. Understand our issue management process by reading about the lifecycle of an issue. Think you've found a bug? Please consider submitting a reproduction project via the spring-framework-issues GitHub repository. The readme there provides simple step-by-step instructions.

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 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.

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.

Contributing

Pull requests are welcome; see the contributor guidelines for details.

Staying in Touch

Follow @SpringCentral as well as @SpringFramework and its team members on Twitter. In-depth articles can be found at The Spring Blog, and releases are announced via our news feed.

License

The Spring Framework is released under version 2.0 of the Apache License.

About

Spring 4.3.10版本源码,用于学习Spring源码添加中文注释及本地调试代码

License:Apache License 2.0


Languages

Language:Java 99.4%Language:AspectJ 0.1%Language:Groovy 0.1%Language:HTML 0.1%Language:CSS 0.1%Language:FreeMarker 0.0%Language:GAP 0.0%Language:Shell 0.0%Language:Batchfile 0.0%Language:XSLT 0.0%Language:Ruby 0.0%Language:TSQL 0.0%Language:Smarty 0.0%Language:JavaScript 0.0%Language:Python 0.0%