1. 程式人生 > 實用技巧 >Spring——初識

Spring——初識

1.1 使用
  1. 導包:Spring Web MVC(maven)

    <!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>5.2.5.RELEASE</version>
    </dependency>
    
  2. 整合Mybatis:spring -jdbc

    <!-- https://mvnrepository.com/artifact/org.springframework/spring-jdbc -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>5.2.5.RELEASE</version>
    </dependency>
    
1.2 優點
  1. 是一個開源的免費框架(容器)
  2. 是一個輕量級的,非入侵式(引入後不會改變原本程式碼的情況)的框架
  3. 控制反轉(IOC),面向切片程式設計(AOP)
  4. 支援事務的處理,對框架的支援

總結: spring是輕量級的控制權反轉(IOC),切面程式設計(AOP)的框架

1.3 缺點:配置繁瑣(所以後面發展出了springBoot)
1.4 七大模組

1.5 拓展

  1. springboot:
    • 快速開發的腳手架
    • 可以用於快速開發單個微服務
    • 約定大於配置
    • 學習springBoot的前提,需要掌握spring及springMVC
  2. springCloud:
    • 是基於springboot實現