全面开战系列之Spring源码---Spring概述(一)

 


系列文章目录

前言

在写这系列文章前,我先狠狠的打了自己两个巴掌,看了看之前Mybatis源码系列的时间在7月底,至今2个半月没写博客了。痛斥自己的懒惰,当真是声泪俱下,刻骨铭心。但今天终于重拾初心,继续征战。

本系列主要探讨Spring框架,系列名定为:全面开战! 一起冲

一、Spring概述

Spring 框架分为多个模块。应用程序可以选择所需的模块,IOC和AOP是这个Spring的核心模块。除此之外,Spring 框架为不同的应用程序体系结构提供了基础支持,包括消息传递,事务性数据和持久性以及 Web。

本系列聚焦于IOC和AOP两大模块。

二、源码阅读步骤

1.下载源码

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

spring版本:5.1.X

下载后将项目导入IDEA

2.基本配置

2.1

在项目中,找到test文件夹,找到java文件夹,这里面可以看到各种模块的测试用例,照着写一个用例,开始Debug。

创建一个类:HelloService

public class HelloService {
   public void setName(String name){
      this.name = name;
   }

   public String getName() {
      return name;
   }

}

创建配置文件:MyTestApplication.xml,放在 resources资源文件夹下

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
   <bean id="helloService" class="org.springframework.context.mytest.HelloService"></bean>
</beans>

创建测试用例:

public class MyContestTests {
   @Test
   public void sayHello(){
      ApplicationContext context = new ClassPathXmlApplicationContext("classpath:MyTestApplication.xml");
      HelloService helloService = context.getBean("helloService",HelloService.class);
      helloService.sayHello();
   }
}

总结

以上是源码阅读的开端。不过在开始阅读源码之前,建议先看看Spring文档。接下来即将正式进入源码阅读

中文文档:https://www.docs4dev.com/docs/zh/spring-framework/5.1.3.RELEASE/reference/overview.html

官方文档:https://docs.spring.io/spring-framework/docs/5.1.18.RELEASE/spring-framework-reference/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值