Spring框架是一种轻量级的、一站式的企业级开发解决方案
框架(framework):是一组设计思想、规范、API的精心组合,专门用来解决某一层次或领域的问题
轻量级(lightweight):此处是相对于EJB框架来说的,在资源占用、开发部署维护、学习成本等方面Spring都比EJB轻便
一站式(full-stack):即一步到位,Spring本身提供了丰富的功能特性,又直接整合了一批优秀框架,对于那些没有直接整合的其他框架,也提供了一层简单的封装让开发人员可以方便的手动整合,即Spring可以满足项目各个层次的要求。
Spring框架有众多模块,各个模块相互独立又能很好的合作
就我们现阶段的学习目标来说,上面这张图太过复杂,可简化如下:
整个Spring有三个核心模块:Spring容器、Spring AOP、声明式事务管理。这也是我们将要重点学习的内容
向maven项目添加Spring依赖:
<dependencies> <!-- spring最基本的环境支持依赖,会传递依赖core、beans、expression、aop等模块 --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>4.3.2.RELEASE</version> </dependency>
<!-- 提供了对其他第三方库的内置支持,如quartz等 --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>4.3.2.RELEASE</version> </dependency>
<!-- spring处理对象关系映射的模块,传递依赖了jdbc、transaction等模块 --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>4.3.2.RELEASE</version> </dependency>
<!-- spring对面向切面编程的支持 --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aspects</artifactId> <version>4.3.2.RELEASE</version> </dependency>
<!-- spring处理前端表现层的模块,即springMVC --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>4.3.2.RELEASE</version> </dependency> <!-- 第三方定时器框架 --> <dependency> <groupId>org.quartz-scheduler</groupId> <artifactId>quartz</artifactId> <version>2.2.3</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> </dependency>
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.37</version> </dependency>
<!-- c3p0依赖 --> <dependency> <groupId>com.mchange</groupId> <artifactId>c3p0</artifactId> <version>0.9.5</version> </dependency> </dependencies>
<build> <plugins> <!-- 指定JDK编译版本 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build> |