一,源码下载
https://codeload.github.com/spring-projects/spring-framework/zip/master
二,gradle下载及配置:
# mac下gradle安装
brew install gradle
# 查看安装目录
brew info gradle
三,工程配置:
gradle配置
项目配置
下载gradle无法自动下载的jar包:展开左侧gradle ——> spring-core ——>other ——>
compileJavaTest 双击直到build successful
编译项目 运行任意一个spring-context ——>中的test模块
四,源码导入成功测试:
4.1.spring源码结构:(添加了一个OwnLearnSpring模块,用于学习测试)
4.2.小demo测试:
domeo目录结构:
2-1:
package com.learn;
import org.springframework.context.annotation.ComponentScan;
@ComponentScan("com.learn")
public class Appconfig {
}
2-2:
package com.learn;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
public class BuildTest {
public static void main(String[] args) {
AnnotationConfigApplicationContext annotationConfigApplicationContext=new AnnotationConfigApplicationContext(Appconfig.class);
System.out.println("showGetBean===>"+annotationConfigApplicationContext.getBean(BuildTestService.class));
}
}
2-3:
package com.learn;
import org.springframework.stereotype.Service;
@Service
public class BuildTestService {
}
2-4:
配置文件:
plugins {
id 'java'
}
group 'org.springframework'
version '5.1.15.BUILD-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
compile(project(":spring-context"))
testCompile group: 'junit', name: 'junit', version: '4.12'
3.demo测试成功