idea 2020.1 build spring source code, and finally succeeded in one afternoon!

Environment gradle 6.5 JDK 11 spring source code version: 5.2X

Domestic code cloud download code
https://gitee.com/mirrors/Spring-Framework.git

The gradle environment variables don't seem to be very important. Most people on the Internet say that they are equipped with environment variables, but they also failed before, but I still got them.
Insert picture description here

After downloading, idea will directly force the download of gradle.zip this operation, so directly close idea, find the code just downloaded, in the
gradle/wapper directory, there is a gradle-wrapper.properties
Insert picture description here
open like
Insert picture description here
this. For
example, I am gradle in D :\grade

Insert picture description here
I changed to

file:///D:/grade/gradle-6.5-all.zip

Insert picture description here

There are two more things to change if you want to compile spring successfully
Insert picture description here

settings.gradle plus this configuration

maven {
    
     url "https://maven.aliyun.com/repository/public" }

Insert picture description here
build.gradle plus

allprojects {
    
    
			repositories {
    
    
				maven{
    
     url 'http://maven.aliyun.com/nexus/content/groups/public/'}
				maven {
    
     url 'https://maven.aliyun.com/repository/gradle-plugin' }
				maven {
    
     url 'https://maven.aliyun.com/repository/google' }
				maven {
    
     url 'https://maven.aliyun.com/repository/jcenter'}
			}
		}

Insert picture description here
With this configuration, you will still download some jars when you open it, wait for about 10 minutes to work, you may have to try several times
Insert picture description here

Don't see a green tick and think it's finished, it's just that its jar has been downloaded.

Insert picture description here
Change to JDK11

Insert picture description here

Click on
Insert picture description here

Run spring's own test case after ok
Insert picture description here
Insert picture description here

This can be seen, there is only 1 error, ignore
Insert picture description here

After completion, simply write some test
Insert picture description here
codes as follows

package com.yu;

import org.springframework.stereotype.Component;

/**
 * Created by IntelliJ IDEA.
 *
 * @author IT 贱男
 * description:
 * date: 2020/8/14 09:34
 */
@Component
public class User {
    
    
 
	public String name = "yuyu";
}
package com.yu;

import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.ComponentScan;

/**
 * Created by IntelliJ IDEA.
 *
 * @author IT yu
 * date: 2020/10/27 09:52
 */
@Configurable
@ComponentScan("com.yu")
public class AppConfig {
    
    
}
package com.yu;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;


public class Test {
    
    
 
	public static void main(String[] args) {
    
    
		AnnotationConfigApplicationContext context =
				new AnnotationConfigApplicationContext(AppConfig.class);
		User user = (User) context.getBean("user");
		System.out.println(user.name);
	}
}

carry out
Insert picture description here

Guess you like

Origin blog.csdn.net/yuyue_999/article/details/109313178