二 、 Spring 学习笔记 之 Spring 框架的演变

Spring框架自RodJohnson的书籍《ExpertOne-on-One:J2EEDesignandDevelopment》中诞生,经历了从0.9版本到5.x的主要迭代,不断引入新特性,如AOP、MVC、REST支持等,同时优化了Java配置、异步处理、测试框架,以及全面拥抱Java8和反应式编程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

        Spring 框架源自 Rod John son 编写的 Expert One-on-One: J2EE Design and Development 一书 (Wrox 出版社,
2002 年出版)。在过去十年 中, Spring 框架在核心功能、相关项目以及社区支持方面发展迅猛 。 随着 Spring 框架
的新主要版本的推出,有必要快速回顾一下 Spring 的每个里程碑版本所带来的重要特性,并最终发展到 Spring
Framework 5.0 。

  • Spring 0 .9 :这是该框架第一个公开发布的版本,以 Expert One-on-One: J2EE Design and Deν'e!opment 一书

为基础,提供了 bean 配置基础、 AOP 支持、 JDBC 抽象框架、抽象事务支持等。 该版本没有官方参考文档 ,
但可以在 SourceForge 上找到现有的源代码和文档  。

  •  Spring 1.x:这是发布的第一个带有官方参考文档的版本 。 它由图 1-1 所示的七个模块组成 。

            + Spring Core: bean 容器以及支持的实用程序 。
            + Spting Context: App licationContext、 UT、验证、开IDI, Enterprise JavaBean(EJB)、远程处理和邮件支持。
            + Spring DAO:事务基础结构、 Java Database Connectivity(JDBC)和数据访问对象(DAO)支持 。
            + Spring ORM:因bemate、 iBATIS 和 Java Data Object(JDO)支持 。
            + Spring AOP : 符合 AOP 联盟的面向方面编程(AOP)实现 。
            + Spting Web:基本集成功能,比如多部分功能、通过 servlet 侦听器进行上下文初始化以及面向 Web 的
应用程序上下文。
            +  Spring Web MVC : 基于 Web 的 Model-View-Controller(MVC)框架 。

  •  Spring 2.x:该版本由图 1-2 所示的六个模块组成。 现在, Spring Context 模块包含在 Spring Core中,而在Spring 2.x 版本中 ,所有的 Spring Web 组件都由单个项目表示 。

 

        + 通过使用新的基于XML Schema 的配置而不是 DTD 格式来简化 XML 配置。值得注意的改进方面包括
           bean 定义、 AOP 以及声明式事务 。
        + 用于 Web 和门户的新 bean 作用域(请求、会话和全局会话) 。
        + 支持 AOP 开发的@AspectJ 注解。
        + Java PersistenceAPI(JPA)抽象层 。
·       + 完全支持异步 JMS 消息驱动的 POJO (用于普通的旧 Java 对象) 。
        + JDBC 简化包括在使用 Java 5+时的 SimpleJdbcTemplate。
        + JDBC 命名参数支持(NamedParameterJdbcTemplate) 。
        + 针对 SpringMVC 的表单标签库 。
       + 对 PortletMVC 框架的介绍 。
       ·+ 动态语言支持 。 可以使用 JRuby、 Groovy 以及 BeanShell 来编写 bean 。
·       + JMX 中的通知支持以及可控的 MBean 注册 。
        + 为调度任务而引入的 TaskExecutor 抽象 。
        + Java 5 注解支持,特别针对@Transactional 、 @Required 和@AspectJ 。

  • Spring 2.5.x:该版本包含以下功能 

        + 名为@Autowired 的新配置注解以及对 JSR-250 注解(@Resource、@PostConstruct 和@PreDestroy)的支持。
        + 新的构造型注解 : @Component 、 @ Repository、 @Service 和@Controller o
        + 自动类路径扫描支持,可以检测和连接带有构造型注解的类。
        + AOP 更新,包括一个新的 bean 切入点元素以及 AspectJ 加载时织入(weaving) 。
        + 完整的 WebSphere 事务管理支持 。
        + 除了 Spring MVC @Controller 注解,还添加了@Request:Mapping、 @Request:Param 和@ModelAttribute 注解,从               而支持通过注解配置进行请求处理 。
        + 支持 Tiles 2 。
        + 支持 JSF 1.2 。
        + 支持 JAX-WS 2.0/2.1 。
        + 引入了 Spring TestContext Framework,提供注解驱动和集成测试支持,不受所用测试框架的影响。
        + 能够将 Spring 应用程序上下文部署为 JCA 适配器 。

  • Spring 3.0.X:这是基于 Java 5 的 Spring 的第一个版本,旨在充分利用 Java 5 的功能,如泛型、可变参数和其他语言改进。 该版本引入了基于 Java 的@Configuration 模型 。 目前己经对框架模块进行了修改, 分别针对每个模块 JAR 使用一棵源、代码树进行管理 。 图 1-3 中对此进行了抽象描述。

        + 支持 Java 5 功能,例如泛型 、 可变参数以及其他改进。
        + 对 Callables 、 Futures 、 ExecutorServi ce 适配器和 ThreadFactory 集成提供很好的支持。
        + 框架模块目前针对每个模块 JAR 都使用→棵源代码树进行分别管理。
        + Spring Expression Language(SpEL)的号 | 入。
        + 核心 Java Config 功能和注解的集成。
        + 通用型转换系统和字段格式化系统。
        + 全面支持 REST 。
        + 新的 MVC XML 名称空间和其他注解,例如 SpringMVC 中的@CookieValue 和@RequestHeaders 。
        + 验证增强功能和 JSR-303(bean 验证)支持。
        + 对 Java EE 6 的早期支持,包括@ Async/@Asynchronou s 注解、 JSR-303 、 JSF 2 .0 、 JPA2 . 0 等 。
        + 支持嵌入式数据库,例如 HSQL 、 H2 和 Derby 。

  • Spring 3.1.x: 该版本包含以下功能。

        + 新的缓冲抽象。
        + 可以用 XML 定义 bean 定义配置文件,同时也支持@Profile 注解。
        + 针对统一属性管理的环境抽象 。
        + 与常见 Spring XML 名称空间元素等价的注f晖, 如@CornponentScan、 @EnableTransactionManagernent、
          @EnableCaching、@EnableWebMvc、 @EnableScheduling、@EnableAsync、 @EnableAspectJAutoProxy、
          @EnableLoadTimeWeaving 和@EnableSpringConfigured 。
        + 支持 Hibernate4 。
        + Spring TestContext Framework X才@Configuration 类和 bean 定义配置文件的支持。
        + 名称空间 c:简化了构造函数注入。
        + 支持 Servlet 3 中 Servlet 容器的基于代码的配置。
        + 能够在不使用 persistence.xml 的情况下启动 JPA EntityManagerFactory。
        + 将 Flash 和 RedirectAtttibutes 添加到 SpringMVC 中,从而允许通过使用 HTTP 会话重定向属性
        + URI 模板变量增强功能。
        + 能够使用@Valid 来注解 Spring MVC @RequestBody 控制器方法参数 。
        + 能够使用@RequestPart 来注解 SpringMVC 控制器方法参数。

  • Spring 3.2.x:该版本包含以下功能。

        + 支持基于 Setvlet3 的异步请求处理。
        + 新的 SpringMVC 测试框架。
        + 新的 SpringMVC 注解@ControllerAdvice 和@MatrixVariable 。
        + 支持 RestTemplate 和@RequestBody 参数中的泛型类型 。
        + 支持 Jackson JSON 2 。
        + 支持 Tiles 3 。
        + 现在,@RequestBody或@RequestPart参数的后面可以跟一个Errors参数,从而可以对验证错误进行处理。
        + 能够通过使用 MVC 名称空间和 Java Config 配置选项来排除 URL 模式。
        + 支持没有 Jada Time 的@DateTimeFormat 。
        + 全局日期和时间格式化。
        + 跨框架的并发优化,从而最小化锁定,并改进了作用域/原型 bean 的并发创建 。
        + 新的基于 Gradle 的构建系统 。
        + 迁移到 GitHub(https://github.com/SpringSource/spring-framework) 。
        + 在框架和第三方依赖、中支持精简的 Java SE 7/0penJDK 7。 现在, CGLIB 和 ASM 已经成为 Spring 的一部分 。 除了 AspectJ 1.6,其他版本都支持 AspectJ 1.7 。

  • Spting 4.0x: 这是一个重要的 Spring 版本,也是第一个完全支持 Java 8 的版本 。 虽然仍然可以使用较旧版本的 Java,但 Java SE6 已经提出了最低版本要求 。 弃用的类和方法己被删除,但模块组织几乎相同,如图 1 -4所示。


     

        + 通过新的 www.spring.io/guides 网站上的一系列入门指南提高了入门体验。
        + 从先前的 Spring 3 版本中删除了弃用的软件包和方法 。
        + 支持 Java 8 ,将最低 Java 版本提高到 6 update 18 。
        + Java EE 6 及以上版本现在被认为是 Spring Framework 4 .0 的基准。
        + Groovy bean 定义 DSL,允许通过 Groovy 语法配置 bean 定义 。
        + 核心容器、测试和一般 Web 改进 。
        + WebSocket、 SockJS 和 STOMP 消息 。

  • Spring 4.2 .x:该版本包含以下功能。

        + 核心改进(例如,引入@AliasFor,并修改现有的注解以使用它) 。
        + 全面支持 Hibernate ORM 5.0 。
        + JMS 和 Web 改进 。
        + 对 WebSocket 消息传递的改进 。
        + 测试改进,最引人注目的是引入了@Commit 来替换@Rollback(false),并引入了 AopTestUtils 实用工具类,允许访问               隐藏在 Spring 代理后面的底层对象。

  • Spring 4.3.x : 该版本包含以下功能 。

        +  完善了编程模型 
        +  在核心容器(包含 ASM5.l 、 CGLIB 3.2.4 以及 spring-core.jar 中的 Objenesis 2.4)和 MVC 方面有了相当大的改进 。
        +  添加了组合注解。
        +  Spring TestContext Framework 需要 JUnit4.12 或更高版本 。
        +  支持新的库,包括 Hibernate ORM 5.2 、 Hibernate Validator 5.3 、 Tomcat 8 .5 和 9 .0 、 Jackson 2.8 等。

  • Spring 5.x:这是一个主要版本。 整个框架代码库都基于 Java 8 , 并且自 2016 年 7 月起与 Java 9 完全兼容 。

        + 支持 portlet、 Velocity、 JasperReports、 XMLBeans、 JDO、 Guava 、 Tiles 2 和 Hibernate 3 。
        + 现在, XML 配置名称空间被流式传输到未版本化的模式; 虽然特定版本的声明仍然被支持,但要针对
           最新的 XSD 架构进行验证 。
        + 充分利用 Java 8 的强大功能,从而在性能上得到极大的改进。
        + Resource 抽象为防御 getFile 访问提供了 isFile 指示符。
        + Spring 提供的 Filter 实现完全支持 Servlet 3.1 签名 。
        + 支持 Protobuf3.0 。
        +支持 JMS2.0+和 JPA 2.1+。
        + 引入了 Spring Web Flow , 这是一个用于替代 SpringMVC 的项目,构建在反应式基础之上,这意味着它完全是异步和              非阻塞的,主要用于事件循环执行模型 , 而非传统的每个请求执行模型都带有一个线程的大型线程池(基于 Project                    Reactor 构建) 。
        + Web 和核心模块适用于反应式编程模型。
        + Spring 测试模块有了很大的改进。 现在支持 JUnit5 ,引入了新的注解来支持 Jupiter 编程和扩展模型,例如@                             SpringJUnitConfig、@SpringJUnitWebConfig、@Enabledlf 和 @Disabledlf。
        + 支持在 Spring TestContext Framework 中实现并行测试执行 

 

         可以从 SourceForge 站点下载 Spring 的早期版本(包括 0.9 版本):

         https://sourceforge.net/projects/springframework/files/springframework/

 What is this book about? The results of using J2EE in practice are often disappointing: applications are often slow, unduly complex, and take too long to develop. Rod Johnson believes that the problem lies not in J2EE itself, but in that it is often used badly. Many J2EE publications advocate approaches that, while fine in theory, often fail in reality, or deliver no real business value. "Expert One-on-One: J2EE Design and Development" aims to demystify J2EE development. Using a practical focus, it shows how to use J2EE technologies to reduce, rather than increase, complexity. Rod draws on his experience of designing successful high-volume J2EE applications and salvaging failing projects, as well as intimate knowledge of the J2EE specifications, to offer a real-world, how-to guide on how you too can make J2EE work in practice. It will help you to solve common problems with J2EE and avoid the expensive mistakes often made in J2EE projects. It will guide you through the complexity of the J2EE services and APIs to enable you to build the simplest possible solution, on time and on budget. Rod takes a practical, pragmatic approach, questioning J2EE orthodoxy where it has failed to deliver results in practice and instead suggesting effective, proven approaches. What does this book cover? In this book, you will learn When to use a distributed architecture When and how to use EJB How to develop an efficient data access strategy How to design a clean and maintainable web interface How to design J2EE applications for performance Who is this book for? This book would be of value to most enterprise developers. Although some of the discussion (for example, on performance and scalability) would be most relevant to architects and lead developers, the practical focus would make it useful to anyone with some familiarity with J2EE. Because of the complete design-deployment coverage, a less advanced developer could work through the book along with a more introductory text, and successfully build and understand the sample application. This comprehensive coverage would also be useful to developers in smaller organisations, who might be called upon to fill several normally distinct roles. What is special about this book? Wondering what differentiates this book from others like it in the market? Take a look: It does not just discuss technology, but stress its practical application. The book is driven from the need to solve common tasks, rather than by the elements of J2EE. It discuss risks in J2EE development It takes the reader through the entire design, development and build process of a non-trivial application. This wouldn't be compressed into one or two chapters, like the Java Pet Store, but would be a realistic example comparable to the complexity of applications readers would need to build. At each point in the design, alternative choices would be discussed. This would be important both where there's a real problem with the obvious alternative, and where the obvious alternatives are perhaps equally valid. It emphasizes the use of OO design and design patterns in J2EE, without becoming a theoretical book ,高清文档 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值