Spring——初識
阿新 • • 發佈:2020-07-27
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>
-
整合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 優點
- 是一個開源的免費框架(容器)
- 是一個輕量級的,非入侵式(引入後不會改變原本程式碼的情況)的框架
- 控制反轉(IOC),面向切片程式設計(AOP)
- 支援事務的處理,對框架的支援
總結: spring是輕量級的控制權反轉(IOC),切面程式設計(AOP)的框架
1.3 缺點:配置繁瑣(所以後面發展出了springBoot)
1.4 七大模組
1.5 拓展
- springboot:
- 快速開發的腳手架
- 可以用於快速開發單個微服務
- 約定大於配置
- 學習springBoot的前提,需要掌握spring及springMVC
- springCloud:
- 是基於springboot實現