SpringFrame5.1源码阅读环境构建

本文使用工具如下

  • gradle5.1

  • IDEA2021.2

  • JDK1.8

  • SpringFrame5.1

如果是第一次构建SpringFrame源码环境,请严格按照本文给出的这些版本号去尝试

拉取SpringFrame5.1项目

git地址:https://github.com/spring-projects/spring-framework/

git命令输入如下指令:

git clone https://github.com/spring-projects/spring-framework.git
cd spring-framework/
git checkout 5.1.x

项目启动

修改配置

修改build.gradle配置

修改源码的build.gradle文件内容,添加aliyun镜像

在这里插入图片描述

maven { url "http://maven.aliyun.com/nexus/content/groups/public" }

修改gradle-wrapper.properties配置

在这里插入图片描述

修改gradle-wrapper.properties配置,将gradle的版本提高至gradle5.1

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

然后使用IDEA打开项目。

IDEA设置

安装Kotlin插件

在这里插入图片描述

修改JDK编译版本

一共有四个地方需要修改

setting配置:

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

Project Structure配置:

在这里插入图片描述

测试

添加一个自己的module,如下图

在这里插入图片描述

在这里插入图片描述

构建完成后,选择创建module的build.gradle文件添加spring相关依赖并创建自己想的结构,如下图:

在这里插入图片描述

在这里插入图片描述

测试类内容(就把他当做简单的Spring项目对待就好了):

package com.edu.client.mainclient;

import com.edu.client.config.SpringClientConfig;
import com.edu.client.pojo.Student;
import com.edu.client.service.StudentService;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.List;

public class ClientTest01 {
	public static void main(String[] args) {
		AnnotationConfigApplicationContext annotationConfigApplicationContext =
				new AnnotationConfigApplicationContext(SpringClientConfig.class);
		StudentService studentService = annotationConfigApplicationContext.getBean(StudentService.class);
		Student student = annotationConfigApplicationContext.getBean(Student.class);
		List<Student> studentList = studentService.getStudentList();
		studentList.forEach(System.out::println);
		System.out.println(student);
	}
}

如下图就是成功了,如图:
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

five-five

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值