Spring

基礎概念

1.Spring 是一個輕量級的 IOC/DI 和 AOP 容器的開源框架。使用Spring框架的好處是什麼?

2.什麼是IOC(控制反轉)思想?Spring中關於IOC思想的具體方式DI(依賴注入)?這篇文章

  • IOC(inverse of control):控制反轉
    對象的創建以及依賴關係可以由spring完成和注入,即,在應用程序中對象的創建、銷燬等不再由程序本身的編碼實現,而是由外部的Spring容器在程序運行時根據需要注入到程序中,也就是對象的生命週期不是由程序本身來決定,而是由容器來控制,所以稱之爲控制反轉。
  • DI,依賴注入(Dependency Injection)
    1.Spring實現IoC思想是通過DI實現
    2.注入方式:這篇文章
        使用Setter方法注入(需要加註解@Autowired等,或者自己創建Bean,調用該Setter方法設進去);
        構造器注入 (需要加註解@Autowired等,或自己創建Bean,放入構造器中創建);

3.Spring中核心組件Bean、Context、Core看這裏

  • ApplicationContext通常的實現是什麼?
    FileSystemXmlApplicationContext:從絕對路徑中加載xml配置文件
    ClassPathXmlApplicationContext:從項目的編譯路徑下加載xml
    XmlWebApplicationContext:從項目的WEB-INF路徑下加載xml
  • Spring Context初始化流程

4.AOP是什麼?

具體開發相關

5.Spring配置的方式:xml、註解、API

6.Spring自動裝配:byName、byType、Constructor、Autodetect(spring3.0之後過時,不再支持)

7.Spring自動裝配集合:註解和xml

8.Spring內部bean、外部bean、父子bean

9.Spring常用的註解

  • 類型類:
    @Controller、@Service、@Repository、@Component、@Configuration
  • 設置類:
    @Required、@Autowired和@Qualifier、@Scope
  • Web類:
    @RequestMapping&&@GetMapping&&@PostMapping、@PathVariable&&@RequestParam、@RequestBody&&@ResponseBody
  • 功能類
    @ImportResource、@ComponentScan、@EnableCaching&&Cacheable、@Transactional、@Aspect&&@Pointcut、@Scheduled

具體機制和實現原理

10.Spring中Placeholder動態替換機制和實現原理,有兩種實現方式:PropertyPlaceholderConfigurer(常用)、PropertySourcesPlaceholderConfigurer

11.AOP實現的兩種方式靜態代理和動態代理

12.Spring中的事務

  • 隔離級別和傳播類型

13.Spring中核心接口和類:ApplicationContext、BeanFactory、BeanWrapper、FactoryBean

14.Spring中bean的作用於Scope

15.Spring的事件機制:ContextRefreshedEvent、ContextStartedEvent、ContextStoppedEvent、ContextClosedEvent、RequestHandledEvent

 

 

 

 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章