1, 配置环境
- 1 拉取源代码
- 先fokr
- chrome 浏览器 安装 GitHub加速 扩展程序
- 客户端拉取 image.png
- 命令拉取
git clone -b 5.0.x https://gitee.com/mirrors/Spring-Framework.git
- 2 安装 gradle
- 版本 4.7
- 配置环境变量
GRADLE_HOME D:\softwareStudy\gradle-4.7
path 加上 %GRADLE_HOME%\bin
GRADLE_USER_HOME E:\softwareInfo\mavnRepo
# 用户目录添加 .gradle 文件添加 init.gradle 文件
allprojects{
repositories {
def REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content/groups/public/'
all { ArtifactRepository repo ->
if(repo instanceof MavenArtifactRepository){
def url = repo.url.toString()
if (url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('https://jcenter.bintray.com/')) {
project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL."
remove repo
}
}
}
maven {
url REPOSITORY_URL
}
}
}
-
3 cmd 源码路径 执行 gradlew :spring-oxm:compileTestJava
-
4 安装 aspectj
- java -jar aspectj-1.9.1.jar
-
5 idea 导入
- File -> New -> Project from Existing Sources -> Navigate to directory -> Select build.gradle
- image.png
- 假如 Error:(30, 41) java: 找不到符号
符号: 类 DefaultNamingPolicy- 方法一 执行可能报错 gradle objenesisRepackJar, gradle cglibRepackJar
- 方法二 image.png
- aspect 设置
- image.png
- image.png
- 剩下报错的 都是测试类 全删了
-
6 新建测试module
- image.png
// 加入依赖 build.gradle
compile(project(":spring-beans"))
compile(project(":spring-core"))
optional(project(":spring-aop"))
optional(project(":spring-context"))
//写一个测试类
@Component("ibean")
public class IBean {
private String name = "mg";
private String id = "1";
public String getName() {
return name;
}
}
public class IBeanTest {
@Test
public void getBean() {
AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext();
annotationConfigApplicationContext.scan("com.mg.bean");
annotationConfigApplicationContext.refresh();
IBean ibean = (IBean) annotationConfigApplicationContext.getBean("ibean");
System.out.println(ibean.getName());
}
}
- image.png
网友评论