包含标签 源码阅读 的文章

Spring 源码之获取Bean

Spring源码解读之获取Bean 上一篇文章我们搭建了源码环境,并使用了Spring方法获取了Bean,我们下边来回顾下代码 package com.pv3; import com.pv3.config.AnnotationConfig; import com.pv3.utils.TestUtil; import org.springframework.context.annotation.AnnotationConfigApplicationContext; public class Test { public static void main(String[] args) { //启动Spring AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext(AnnotationConfig.class); TestUtil bean = annotationConfigApplicationContext.getBean(TestUtil.class); bean.hello(); } } Spring初始化做了什么? AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext(AnnotationConfig.class); 1、AnnotationConfigA

阅读全文

Spring 源码调试环境

gradle安装教程 本地必须有JAVA环境 [root@localhost ~]# java -version java version "1.8.0_221" Java(TM) SE Runtime Environment (build 1.8.0_221-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode) 执行命令 brew install gradle 搭建Spring源码 下载Spring git clone git@github.com:spring-projects/spring-framework.git 阅读文档 import-into-idea.md 预编译Spring ./gradlew cleanIdea :spring-oxm:compileTestJava 排除模块 spring-aspects 这个不排除Idea报错 启动Spring 配置文件 package com.pv3.config; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @Configuration @ComponentScan("com.pv3") public class AnnotationConfig { } 编写Bean package com.pv3.utils; import org.springframework.stereotype.Component; @Component

阅读全文