Spring source code analysis 1 – source code download, compile, import


Basic information of spring

Rod Johnson, the author of spring, graduated from the Department of computer science at the University of Sydney. Later, he studied for a PhD in musicology because of his love of music. To quote a sentence: the ultimate of programming is art, and art is interlinked. So there is a famous saying in the industry: Spring redefines Java, so we can see the importance of spring. We expect to improve our coding level by learning spring source code.

get ready
Spring source code version: spring 5.1.3.release
JDK version: 1.8
IDE development tool: idea.
Version management tool: Git
Automated build management tool: gradle latest version

Spring source code download
Use the command terminal to enter the source code download folder address to execute the following command
git clone –branch v5.1.3.RELEASE https://gitee.com/Z201/spring…

Go to the downloaded spring source code path and execute the gradlew command, gradlew: spring- oxm:compileTestJava
Mac sometimes can’t recognize gradlew,
You need to authorize gradlew
sudo chmod +x gradlew
And use. / gradlew to call
./gradlew :spring-oxm:compileTestJava

Open the spring source project with idea, install the plug-in kotlin in idea, and restart idea
Create a new one in the spring context module
1. Customize packages and beans and add annotation @ component on the class (the class needs to be scanned and loaded during testing)

public class Student {
  String Name: "my name is spring";
  String password;

  public String getName() {
      return name;

  public void setName(String name) {
      this.name = name;

  public String getPassword() {
      return password;

  public void setPassword(String password) {
      this.password = password;

2. Test classes, such as: new com.xxx.test package, new mytest class and method

public class MyTest {
  public void testAnnotation() {
      //Scan loading, the current AC loading mode
      AnnotationConfigApplicationContext context = new   AnnotationConfigApplicationContext("com.xxxx.bean");
      Student student = (Student) context.getBean("student");

3. Printing the following information is successful

"My name is spring"