
spring
文章平均质量分 78
hhcui重名了
这个作者很懒,什么都没留下…
展开
-
Spring全注解解析
Spring注解@Configuration,@Bean,@Configurationpublic class MainConfig {@Beanpublic Person person(){return new Person();}}@Configuration,相当于以前的xml配置的beans标签,@Bean,就是调用@Bean标注的方法,往beanFactory注册这个bean。bean的默认名字是方法名,假如想指定bean的名字,使用@Bean(value=“XXX”)。@S原创 2021-09-02 22:18:56 · 115 阅读 · 0 评论 -
SpringMVC总体流程与源码分析
SpringMVCSpringMVC总体流程图首先请求进入DispatcherServlet 由DispatcherServlet 从HandlerMappings中提取对应的Handler此时只是获取到了对应的Handle,然后得去寻找对应的适配器,即:HandlerAdapter拿到对应HandlerAdapter时,这时候开始调用对应的Handler处理业务逻辑, 执行完成之后返回一个ModeAndView这时候交给我们的ViewResolver通过视图名称查找出对应的视图然后返回最后原创 2021-08-17 16:58:06 · 81 阅读 · 0 评论 -
mybatis结合spring执行Sql的流程
mybatis执行Sql的流程首先讲上一篇出现过的一段代码new SqlSessionTemplate public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) { if (!this.externalSqlSession) { this.sqlSession = new SqlSessionTemplate(sqlSessionFactory); } }进入new SqlSessio原创 2021-05-26 14:44:59 · 526 阅读 · 0 评论 -
Springboot如何实现自动装配
Springboot如何实现自动装配首先附上springboot启动的整理流程图,可以发现实现自动装配的主要是里面的两个流程prepareContext()和refreshContext()。下面就让我们进入这两个方法,去分析spring如何完成自动装配。prepareContext()prepareContext里面的核心方法是load(context, sources.toArray(new Object[0]));,sourcce就是我们的main函数所在的类。创建一个loader用于原创 2021-05-21 22:54:48 · 572 阅读 · 0 评论 -
Spring如何解决循环依赖
Spring如何解决循环依赖先建立循环依赖的demo代码dao中引用了service,service引用了dao。Dao代码@Componentpublic class MyDao { @Autowired MyService service; public MyService getService() { return service; } public void setService(MyService service) { this.service = servic原创 2021-05-19 16:39:14 · 169 阅读 · 0 评论 -
基于注解的spring源码解析之读懂refresh方法之finishBeanFactoryInitialization(beanFactory)
基于注解的spring源码解析之读懂refresh方法之finishBeanFactoryInitialization(beanFactory)接着上一篇文章,BD里面现在有8个属性实例化bean进入finishBeanFactoryInitialization(beanFactory)方法,安装流程图一路点进去,获得bean的构造方法,然后进行实例化。填充属性populateBean(beanName, mbd, instanceWrapper);...原创 2021-05-17 21:47:06 · 153 阅读 · 0 评论 -
基于注解的spring源码解析之读懂refresh方法,refresh方法的总体流程
基于注解的spring源码解析2-读懂refresh方法ynchronized (this.startupShutdownMonitor) { // Prepare this context for refreshing. ////准备工作包括设置启动时间,是否激活标识位, // 初始化属性源(property source)配置 prepareRefresh(); // Tell the subclass to refresh the internal bean fact原创 2021-05-17 11:30:24 · 310 阅读 · 1 评论 -
基于注解的spring源码解析之总体流程
基于注解的spring源码解析1-总体流程##总体流程图Demo代码public class Main { public static void main(String[] args) { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class); MyService service = (MyService) context.getBean("serv原创 2021-05-17 11:05:16 · 171 阅读 · 0 评论 -
Spring提供的扩展点以及案例
Spring提供的扩展点以及案例1 BeanFactoryPostProcessor/** * spring的扩展点之一 * 实现该接口,可以在spring的bean创建之前修改bean的定义属性。 * spring允许BeanFactoryPostProcessor在容器实例化任何其它bean之前读取配置元数据, * 并可以根据需要进行修改,例如可以把bean的scope从singleton改为prototype,也可以把property的值给修改掉。 * 可以同时配置多个BeanFacto原创 2021-05-18 17:53:32 · 437 阅读 · 0 评论 -
基于注解的spring源码解析之读懂refresh方法之invokeBeanFactoryPostProcessors()
基于注解的spring源码解析之读懂refresh方法之invokeBeanFactoryPostProcessors()进入方法invokeBeanFactoryPostProcessors() protected void invokeBeanFactoryPostProcessors(ConfigurableListableBeanFactory beanFactory) { //获取自定义的,手工add进去list的beanFactoryProcessors PostProcessorR原创 2021-05-17 14:55:50 · 104 阅读 · 0 评论