spring框架
Spring Framework is one of the most popular Java EE frameworks.
Spring框架是最受欢迎的Java EE框架之一。
In this article, we will learn about the following:
在本文中,我们将学习以下内容:
- Spring framework architecture Spring框架架构
- Core components of Spring Spring的核心组件
- Various projects under the spring framework umbrella. 春天框架下的各种项目。
I looked at the Google Trends chart for Spring Framework, Servlet, JSP, and JSF. It’s clear that Spring is far ahead from all other Java EE technologies.
我查看了Spring框架,Servlet,JSP和JSF的Google趋势图表。 显然,Spring远远领先于所有其他Java EE技术。
![Spring Framework Popularity](https://cdn.journaldev.com/wp-content/uploads/2017/11/spring-framework-popularity.png)
Spring Framework – Google Trends
Spring Framework – Google趋势
什么是Spring Framework? (What is Spring Framework?)
Spring is one of the most popular frameworks for Java enterprise edition.
Spring是Java企业版最受欢迎的框架之一。
Developers all over the world use Spring for developing reliable and high-quality applications.
全世界的开发人员都使用Spring开发可靠和高质量的应用程序。
The spring framework was designed by Rod Johnson. Since then Spring has become an alternative technology in Java world for the EJB model.
弹簧框架是由Rod Johnson设计的。 从那时起,Spring成为Java世界中EJB模型的替代技术。
You can create different kinds of applications using the spring framework.
您可以使用spring框架创建各种类型的应用程序。
Spring核心概念– DI,IoC,AOP (Spring Core Concepts – DI, IoC, AOP)
- It is impossible to understand what is Spring Framework without understanding what is Dependency Injection and Inversion of Control. Dependency Injection also called as DI, is one of the types of Inversion of Control (IoC). 如果不了解什么是依赖注入和控制反转,就不可能了解什么是Spring Framework。 依赖注入也称为DI,是控制反转(IoC)的类型之一。
- Inversion of Control – this is the principle of object-oriented programming, in which objects of the program do not depend on concrete implementations of other objects, but may have knowledge about their abstractions (interfaces) for later interaction. 控制反转 -这是面向对象编程的原理,其中程序对象不依赖于其他对象的具体实现,但可能具有有关其抽象(接口)的知识,以便以后进行交互。
- Dependency Injection – is a composition of structural design patterns, in which for each function of the application there is one, a conditionally independent object (service) that can have the need to use other objects (dependencies) known to it by interfaces. Dependencies are transferred (implemented) to the service at the time of its creation. This is a situation where we introduce an element of one class into another. In practice, DI is implemented by passing parameters to the constructor or using setters. Libraries that implement this approach are also called IoC containers. 依赖注入 –是结构设计模式的组成,其中对于应用程序的每个功能都有一个条件独立对象(服务),可能需要使用接口已知的其他对象(依赖项)。 在创建服务时,依赖关系已传输(实现)到服务。 在这种情况下,我们将一个类的元素引入另一个类。 实际上,DI是通过将参数传递给构造函数或使用setter来实现的。 实现此方法的库也称为IoC容器。
- Aspect oriented programming – a programming paradigm that allows you to distinguish cross-through (functional) functionality in application. These functions, which span multiple application nodes, are called cross-cutting concerns and these cross-cutting notes are separated from the immediate business logic of the application. In OOP, the key unit is the class, while in AOP, the key element is the aspect. DI helps to separate application classes into separate modules, and AOP helps to separate cross-cutting concerns from the objects they affect. 面向方面的编程 –一种编程范例,可让您区分应用程序中的穿越(功能)功能。 这些跨越多个应用程序节点的功能称为跨领域关注点,并且这些跨领域注释与应用程序的直接业务逻辑分开。 在OOP中,关键单元是类,而在AOP中,关键元素是方面。 DI帮助将应用程序类分离到单独的模块中,而AOP帮助将横切关注点与它们所影响的对象分离。
Spring框架架构 (Spring Framework Architecture)
Spring Framework is divided into a number of separate modules, which allows you to decide which ones to use in your application. The below image illustrates the most important modules of Spring Framework architecture.
Spring Framework分为多个独立的模块,可让您决定在应用程序中使用哪些模块。 下图说明了Spring Framework体系结构中最重要的模块。
Let’s look into spring ecosystem modules one by one.
让我们逐一研究Spring生态系统模块。
Spring Framework核心组件 (Spring Framework Core Components)
The Core container from Spring consists of four modules: SpEL , Context, Core, Beans. Description for these elements are as follows:
Spring的Core容器包含四个模块:SpEL,Context,Core,Beans。 这些元素的说明如下:
- The SpEL module provides a powerful expression language for manipulating objects during execution. SpEL模块提供了一种功能强大的表达语言,用于在执行过程中操纵对象。
- Context is built on the basis of Beans and Core and allows you to access any object that is defined in the settings. The key element of the Context module is the ApplicationContext interface. 上下文是基于Beans和Core构建的,它允许您访问设置中定义的任何对象。 上下文模块的关键元素是ApplicationContext接口。
- The Core module provides key parts of the framework including IoC and DI properties. 核心模块提供了框架的关键部分,包括IoC和DI属性。
- The Bean module is responsible for creating and managing Spring Beans – is application context structure unit. Bean模块负责创建和管理Spring Bean –是应用程序上下文结构单元。
Spring Framework网站 (Spring Framework Web)
Spring framework Web layer consists of Web, Web-MVC, Web-Socket, Web-Portlet etc.
Spring框架Web层由Web,Web-MVC,Web-Socket,Web-Portlet等组成。
- The Web module provides functions such as downloading files, creating web application, rest web service etc. Web模块提供诸如下载文件,创建Web应用程序,REST Web服务等功能。
- Web-MVC contains a Spring MVC implementation for web applications. Web-MVC包含用于Web应用程序的Spring MVC实现。
- Web-Socket provides support for communication between the client and the server, using Web-Sockets in web applications. Web-Socket使用Web应用程序中的Web-Socket提供对客户端与服务器之间通信的支持。
- Web-Portlet provides MVC implementation with portlet environment Web-Portlet通过Portlet环境提供MVC实现
Spring Framework数据访问 (Spring Framework Data Access)
The Data Access/Integration container consists of JDBC, ORM, OXM, JMS and the Transactions module.
数据访问/集成容器由JDBC,ORM,OXM,JMS和Transactions模块组成。
- JDBC provides an abstract layer of JDBC and eliminates the need for the developer to manually register the monotonous code associated with connecting to the database. JDBC提供了JDBC的抽象层,并且使开发人员无需手动注册与连接数据库相关的单调代码。
- Spring ORM provides integration with popular ORMs such as Hibernate, JDO, which are implementations of JPA. Spring ORM提供了与流行的ORM(例如Hibernate,JDO)的集成,这些ORM是JPA的实现。
- The OXM module is responsible for linking the Object / XML – XMLBeans, JAXB, etc. OXM模块负责链接对象/ XML – XMLBeans,JAXB等。
- The JMS (Java Messaging Service) module is responsible for creating, sending and receiving messages. JMS(Java消息服务)模块负责创建,发送和接收消息。
- Transactions supports transaction management for classes that implement certain methods and POJOs. 事务支持对实现某些方法和POJO的类的事务管理。
杂项模块 (Miscellaneous Modules)
Spring also includes a number of other important modules, such as AOP, Aspects, Instrumentation, Messaging, and Test.
Spring还包括许多其他重要模块,例如AOP,Aspects,Instrumentation,Messaging和Test。
- AOP implements aspect-oriented programming and allows using the entire arsenal of AOP capabilities. AOP实现面向方面的编程,并允许使用AOP功能的整个库。
- The Aspects module provides integration with AspectJ, which is also a powerful AOP framework. Aspects模块提供与AspectJ的集成,后者也是一个功能强大的AOP框架。
- Instrumentation is responsible for supporting class instrumentation and class loader, which are used in server applications. 工具负责支持在服务器应用程序中使用的类工具和类加载器。
- The Messaging module provides STOMP support. 消息模块提供STOMP支持。
- Finally, the Test module provides testing using TestNG or the JUnit Framework. 最后,Test模块使用TestNG或JUnit Framework提供测试。
Spring 5功能 (Spring 5 Features)
Spring 5 brought massive update to Spring 4. Some of the important features of Spring 5 are:
春天5带来了大量的更新,春天4.一些重要特点弹簧5是:
- Support for Java 8, Java 9, Java EE 7, Java EE 8, Servlet 4.0, Bean Validation 2.0, and JPA 2.2. I am happy to see that Spring is trying to catch up with latest versions of major technologies being used. 支持Java 8,Java 9,Java EE 7,Java EE 8,Servlet 4.0,Bean验证2.0和JPA 2.2。 我很高兴看到Spring试图赶上正在使用的主要技术的最新版本。
- Improved Logging with new module – spring-jcl. 使用新模块– spring-jcl改进了日志记录。
- File operations are using NIO 2 streams, hence improved performance. 文件操作使用NIO 2流,因此提高了性能。
- Support for Reactor 3.1 Flux and Mono as well as RxJava 1.3 and 2.1 as return values from Spring MVC controller methods. 支持Reactor 3.1 Flux和Mono以及RxJava 1.3和2.1作为Spring MVC控制器方法的返回值。
- Support for Kotlin, Project Lombok, JSON Binding API as an alternative to Jackson and GSON. 支持Kotlin,Project Lombok,JSON Binding API,作为Jackson和GSON的替代方案。
- Spring WebFlux – Spring getting Reactive. Spring WebFlux –春天变得活跃起来 。
- Support for JUnit 5 支持JUnit 5
- Functional programming support through Kotlin. 通过Kotlin提供功能编程支持。
References: Spring Official Website, Spring Reference Documentation
参考资料: Spring官方网站 , Spring参考文档
spring框架