Spring--1--basic

Spring的概念

Spring--1--basic

服务器一般采用三层体系架构,分别为表示层(Web层)、业务逻辑层(Service层)、持久化层(Dao层),Spring对每一层都提供了技术支持。
在表示层提供了与Sturts等框架的整合
在业务逻辑层可以管理事务、记录日志等
在持久化层乐意整合Hibernate、JdbcTemplate等技术

Spring的优点

spring具有简单、可测试和松耦合等特点
非侵入式设计
依赖注入:反向控制(IOC)
方便解耦、简化开发
支持AOP
支持声明式事务处理
方便程序测试
方便集成各种优秀框架
降低Java EE API的使用难度

Spring的体系架构

1、CoreContainer(核心容器)
包括Beans Core Context SpEL
2、Data Accesss/Integration
包括JDBC、OXM、JMS、Transition
3、Web
包括Servlet、Web
4、其他
包括AOP、Aspects、Instrumentation、Messaging

Spring的jar包下载

https://repo.spring.io/simple/libs-release-local/org/springframework/spring/4.3.6.RELEASE/

http://commons.apache.org/proper/commons-logging/download_logging.cgi

Spring 的模块划分图

1、Test:Spring单元测试模块
2、Core Container:核心容器(IOC)黑色代码这些模块由哪些jar包组成。这些jar包都需要导入。

spring-beans-4.3.6.RELEASE
spring-context-4.3.6.RELEASE
spring-expression-4.3.6.RELEASE
spring-core-4.3.6.RELEASE

3、AOP+Aspect(面向切面编程模块)

spring-aop-4.3.6.RELEASE
spring-aspects-4.3.6.RELEASE

4、Data Access(数据集成)

spring-jdbc-4.3.6.RELEASE
spring-orm-4.3.6.RELEASE
spring-tx-4.3.6.RELEASE(事务)

用于integration

spring-oxm-4.3.6.RELEASE 
spring-jms-4.3.6.RELEASE

5、Web应用开发模块

spring-websocket-4.3.6.RELEASE
spring-web-4.3.6.RELEASE  (与原生的web相关,servlet)
spring-webmvc-4.3.6.RELEASE (开发web项目的)
spring-webmvc-portlet-4.3.6.RELEASE  (开发web项目的应用集成)

用哪个模块导哪个包即可。

Spring的核心内容

Spring--1--basic

Spring框架的编写流程

1、导包
根据模块划分图的包,用到哪些包导入哪些包即可。
Spring运行的时候依赖一个日志包,所以还需要导入一个common-logging包
Spring--1--basic
手动右键 -> Build Path ->Add to Build Path
2、写配置
在spring的配置文件中集合了spring的IOC容器管理的所有组件。
因eclipse之前导入了spring的依赖文件,所以在src文件夹下,右键—>new—>other—>Spring Bean Configuration File
Spring--1--basic
注册一个容器:
Spring--1--basic

3、测试
新建一个单元测试文件:new–>JUnit Test Case
若@Test报错,说明标注的编译水平版本过低,给其调高即可。
Spring--1--basic

获取到配置文件

ApplicationContext context=new ClassPathXmlApplicationContext("ioc.xml");

获取到容器

Person bean=(Person)context.getBean("Person01");
上一篇:服务器搭建代理ip


下一篇:【Basic】SVM(支持向量机)分类算法