贵阳地区,哪家彩票网站开发公司能提供定制化网站建设咨询服务?
摘要:彩票网站开发公司,贵阳网站建设咨询,体育新闻最新消息,上海广告传媒有限公司文章目录 一:什么是自动装配二、springboot的启动流程1.调用SpringApplication(
彩票网站开发公司,贵阳网站建设咨询,体育新闻最新消息,上海广告传媒有限公司文章目录 一#xff1a;什么是自动装配二、springboot的启动流程1.调用SpringApplication#xff08;#xff09;的构造方法2.执行核心run方法#xff08;#xff09;3.执行核心prepareContext#xff08;#xff09;4.执行核心refreshContext#xff08;#xff09;5… 文章目录 一什么是自动装配二、springboot的启动流程1.调用SpringApplication的构造方法2.执行核心run方法3.执行核心prepareContext4.执行核心refreshContext5.ConfigurationClassPostProcess 三流程概述四总结 Spring Boot的核心理念是简化Spring应用的搭建和开发过程提出了约定大于配置和自动装配的思想。开发Spring项目通常要配置xml文件当项目变得复杂的时候xml的配置文件也将变得极其复杂。为了解决这个问题我们将一些常用的通用的配置先配置好要用的时候直接装上去不用的时候卸下来这些就是Spring Boot框架在Spring框架的基础上要解决的问题。
一什么是自动装配
在传统的Spring框架中我们需要手动配置和管理Bean的依赖关系但在Spring Boot中大量的配置可以自动完成。这是因为Spring Boot中引入了自动装配的概念。自动装配指的是根据应用程序的依赖关系自动配置Spring Bean而无需手动配置。
手动装配
比如在下面代码中我创建了一个cat和一个dog。然后通过手动方式把他注入到people类的属性cat和dog中。
?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beans xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance xsi:schemaLocationhttp://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsdbean idcat classcom.kuang.pojo.Cat/bean iddog classcom.kuang.pojo.Dog/bean idpeople classcom.kuang.pojo.Peopelproperty namename value张三/property namecat refcat/property namedog refdog//bean/beans
自动装配
spring中实现自动装配的方式有两种一种是通过xml文件、一种是通过注解的方式。
