spring ref &history&design philosophy
Spring Framework Overview
Spring是开发java application的通用框架,分为多个模块(modules),核心是core container,包括configuration model(配置模型)和dependency injection(依赖注入)Spring还可以为多种应用架构(application architecture)提供支持,包括messaging,transaction data, persistence(持久化),web。Spring也提供Servlet-based Spring MVC web framework和Spring WebFlux reactive web framework。
History
Spring最早在2003年,由于J2EE过于复杂而被开发出来的。有人认为Spring和Java EE是竞争关系,但Spring更像是对Java EE的补充。Spring整合了一些EE的标准:
- Servlet API
- WebSocket API
- Concurrency Utilities(并发性)
- JSON Binding API 简介
- Bean Validation(数据校验) 简介
- JPA
- JMS
- Dependency Injection and Common Annotations
Java EE在app开发中的角色在随时间变化。早期的时候,javaEE和Spring开发的应用是部署在application server上的,今天,在Spring Boot的帮助下开发变得友好且更加云端化(devops and cloud-friendly),嵌入Servelet容器,非常容易改变。在Spring Framework5中,一个webflux应用甚至不需要Servlet API并可以运行在不含Servlet容器的server上。
Spring projects目前在逐渐丰富,建立在Spring Framework上的projects有Spring Boot,Spring Security,Spring Data,Spring Cloud,Spring Batch…
Spring的design philosophy
- Provide choice at every level 尽可能允许不改动code的情况下变更design
- Accommodate diverse perspectives 允许设计的灵活性
- Maintain strong backward compatibility 对JDK和第三方库的高兼容性
- Care about API design API被设计地简单易用
- Set high standards for code quality 注意代码的整洁
IoC Container
Introduction
IoC: Inversion of Control(控制反转) 也可称为dependency injection(依赖注入), 定义: it is a process whereby objects define their dependencies (that is, the other objects they work with) only through constructor arguments, arguments to a factory method, or properties that are set on the object instance after it is constructed or returned from a factory method. 容器随后在创建bean时将依赖注入(把需要的对象传入)。这个过程事实上是对bean自身控制实例化或依赖定位(通过直接初始化类或类似Service Locator Pattern机制)的inverse,这就是为什么叫Inversion of Control。
org.springframework.beans
和 org.springframework.context
两个包是Spring Framework的IoC容器的基础。BeanFactory
接口提供了能管理任何类型对象的高级配置机制。简单来说BeanFactory提供了框架配置和基本的功能。ApplicationContext
是BeanFactory
的子接口,它添加了更多特性企业级应用的功能。在Spring中,塑造应用骨架并被IoC容器管理的对象称为bean。一个bean是一个被IoC容器实例化(instantiated),组装(assembled),管理(managed)的对象,bean只是应用中众多对象中的一个。bean和它周围的依赖都会被容器的配置影响。
Container Overview
org.springframework.context.ApplicationContext接口说明了IoC容器,容器负责实例化,配置,集成beans。容器通过阅读配置文件(configuration metadata)知道实例化(或配置,集成)哪些beans。configuration metadata可以是XML,Java annotations(注释)或java code。IoC可以传递对象以使应用更简练并丰富对象间的依赖。
Spring也提供ApplicationContext
接口的一些实现,在实践中经常会创建ClassPathXmlApplicationContext
或FileSystemXmlApplicationContext
的实例。XML是传统的定义configuration metadata的方法。你可以通过一些XML配置(修改配置为支持额外的格式)来让容器使用注释或代码作为metadata。(原文较难理解:you can instruct the container to use Java annotations or code as the metadata format by providing a small amount of XML configuration to declaratively enable support for these additional metadata formats)
在大部分application scenario中IoC容器实例化多个实例并不需要详尽的用户代码,比如说网页应用中创建一个boilerplate只需要几行代码的descriptor。如果使用Spring Tool Suite就甚至只需要鼠标点几下或者键盘敲几下。
how Spring works(图):
Your application classes are combined with configuration metadata so that, after the ApplicationContext
is created and initialized, you have a fully configured and executable system or application.
spring ref &history&design philosophy的更多相关文章
- spring ref history Design philosophy
一.前言 Spring 框架可以说是 Java 开发人员使用的最流行的应用程序开发框架之一.它目前由大量提供一系列服务的模块组成.包括模块容器,为构建横切关注点提供支持的面向切面编程(AOP),安全框 ...
- Spring history&Design Philosophy 简单介绍~
SPRING框架的介绍和历史 Spring Framework是一个开源Java应用程序框架,最初是基于依赖注入(DI)和控制反转(IoC)的原理开发的. Spring Framework已经成长为控 ...
- spring history &design Philosophy
Spring简介 Spring是一个开源框架,它由Rod Johnson创建.它是为了解决企业应用开发的复杂性而创建的.Spring使用基本的JavaBean来完成以前只可能由EJB完成的事情.然而, ...
- Spring history、design philosophy (Spring的历史及设计理念)
一,Spring的发展史 1,Spring1.x 时代 在Spring1.x时代,都是通过xml文件配置bean,随着项目的不断扩大,需要将xml配置分放到不同的配置文件中,需要频繁的在java类和x ...
- Spring Taco Cloud——design视图的创建(含thymeleaf模板遇到的一些小问题)
先来看下综合前两篇内容加上本次视图的成果 可能不是很美观,因为并没有加css样式,我想等整个项目有个差不多的功能实现后再进行页面优化,请谅解 下面我贴上自己定义修改过的Taco的design视图代 ...
- design philosophy
- A Proof of Stake Design Philosophy - PoS权益证明设计理念
之前在EthFans上看到了关于PoS(权益证明)的相关文章(原文链接),本着学习的态度,对这篇文章进行了翻译.第一次翻译关于区块链的文章,有些单词及句子的措辞还不是很准确,如果发现有翻译的不恰当的地 ...
- SpringMVC执行流程及源码分析
SpringMVC流程及源码分析 前言 学了一遍SpringMVC以后,想着做一个总结,复习一下.复习写下面的总结的时候才发现,其实自己学的并不彻底.牢固.也没有学全,视频跟书本是要结合起来一起, ...
- Chapter 4: Spring and AOP:Spring's AOP Framework -- draft
Spring's AOP Framework Let's begin by looking at Spring's own AOP framework - a proxy-based framewor ...
随机推荐
- Lambda表达式概念与基本语法
Lambda表达式是Java 8的重要更新,一个被广大开发者期待已久的新特性.Lambda表达式支持将代码块作为方法参数,Lambda表达式允许使用更简洁的代码来创建只有一个抽象方法的接口(这种接口被 ...
- Visual Studio Code(VS code)你们都在用吗?或许你们需要看一下这篇博文
写在前面 在前端开发中,有一个非常好用的工具,Visual Studio Code,简称VS code. 都不用我安利VS code,大家就会乖乖的去用,无数个大言不惭的攻城狮,都被VS code比德 ...
- 安卓触控一体机的逆袭之路_追逐品质_支持APP软件安卓
显示性能参数 接口:RGB信号 分辨率:1024*600 比例16:9 显示尺寸(A.A.):222.72*(W)*125.28(H)mm 外围尺寸:235.0(W)*143.0(H)*4.5(T)m ...
- Springboot项目打包后的页面丢失问题(thymeleaf报错)
遇到的问题目前找到两种: 返回视图路径以/开头,例如 /test/hello 在thymeleaf页面中,引入的页面以/开头,例如:<footer th:replace="/index ...
- javascript获取当前域名
<script language="javascript">//获取域名host = window.location.host;host2=document.domai ...
- Windows Server 2012安装.NET Framework 3.5
1 文件获取地址 链接:https://pan.baidu.com/s/1o7wykEKKrzbVslSeHbBigA 提取码:e59o 2 安装原因 在Windows Server 2012上安装一 ...
- [mysql] 修复问题表Table '.xxxx' is marked as crashed and should be repaired
程序执行的过程中,出现 Table '.xxxx' is marked as crashed and should be repaired 错误,上网查了一下,原来是表遭到损坏所致,具体修复办法如 ...
- C# 操作Session、Cookie,Url 编码解码工具类WebHelper
using System; using System.Collections.Generic; using System.IO; using System.Net; using System.Text ...
- Flask+SQLAlchemy+alembic+Flask-RESTful使用
前言 其实准备把这篇删掉,先写Flask-restful相关的,后来想想大体框架还是先写出来,这两天踩了很多坑,有的谷歌也没有答案.一直摸索也总算是开始了. 正文 SQLAlchemy/alembic ...
- nginx配置文件,做多个项目代理
web01: server { listen 9988; server_name www.oldboy.com; access_log logs/www.oldboy.com_access.log m ...