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.
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
open like
this. For
example, I am gradle in D :\grade
I changed to
file:///D:/grade/gradle-6.5-all.zip
There are two more things to change if you want to compile spring successfully
settings.gradle plus this configuration
maven {
url "https://maven.aliyun.com/repository/public" }
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'}
}
}
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
Don't see a green tick and think it's finished, it's just that its jar has been downloaded.
Change to JDK11
Click on
Run spring's own test case after ok
This can be seen, there is only 1 error, ignore
After completion, simply write some test
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