preface

This article documents the way the Spring source environment is set up, as well as the holes we tread! Current version: 5.3.2-SNAPSHOT.

Environment to prepare

  1. Git
  2. JDK
    1. The Master branch requires JDK 11
    2. 5.2.x branch, JDK8 is ok
  3. Gradle 6.5.1
  4. IDEA Latest (2020.2.3)

Spring source repository address: github.com/spring-proj…

Download the source code

  1. Clone source
git clone  https://github.com/spring-projects/spring-framework.git
Copy the code
  1. Open with IDEA

    1. Wait until IDEA is loaded.

Note: Branches of Clone can also be specified

git clonehttps://github.com/spring-projects/spring-framework.git - b 5.2 xCopy the code

Or fork to your own warehouse and clone.

Here I fork to my warehouse and clone again.

The current version of the master branch is 5.3.2-snapshot.

Perform the test

  • Right-click the project to create itmodule

  • chooseGradle Java

  • Create the module

  • Add configuration in build.gradle
compile(project(":spring-context"))
Copy the code

  • Create a test class and test it

UserComponent has the @Component annotation, and everything is fine if the application executes. You’re ready to have fun debugging your code.

The problem summary

Compilation fails

Some friends may encounter the following problems if they download zip package directly :(it is not recommended to download zip package directly to build. If you want to know the reason, you can continue to see. In the end, I did not build successfully, but directly built through clone.)

  1. Error as follows:
fatal: not a git repository (or any of the parent directories): .git BUILD SUCCESSFUL in 14s Build scan background action failed. org.gradle.process.internal.ExecException: Process 'command 'git'' finished with non-zero exit value 128 ... Other omittedCopy the code

Git configuration is not available.

  1. This is where you want to add Git

VCS -> Enable Version Control Integration… -> top right Reload All Gradle Projects

Is still an error

fatal: Needed a single revision
Copy the code

  1. Query problem

Address: github.com/spring-proj…

It is recommended to use

$ git clone [email protected]:spring-projects/spring-framework.git
Copy the code

This means that zip distribution is primarily used to share source code, but not necessarily to build it.

  1. Finally, I chose to use the clone method, directly clone down, and then build through.

Missing cglib and Objenesis packages

Kotlin: warnings found and -Weeror specified
Copy the code

There are no spring-cglib-repack and spring-objenesis-repack packages

Just do these two.

The package jdk.jfr cannot be found

import jdk.jfr.Category;
import jdk.jfr.Description;
import jdk.jfr.Event;
import jdk.jfr.Label;
Copy the code

JDK upgrade to 11. Because I am using JDK8 locally, I found an error, JFR package needs to upgrade JDK 11.

If it does not take effect, you can:

IDEA -> File -> Project Structure -> Project

⌘ +;

The relevant data

  1. Spring Repository: github.com/spring-proj…
  2. Spring build documentation: github.com/spring-proj…

Article history

  • ReentrantLock source code, draw a look together!
  • Principle of ReentrantReadWriteLock!
  • How did you resolve the Spring self-invocation transaction failure?