2018-06-14 Spring Framework Overview 5.0Spring Framework Overview

Spring Framework Overview

Spring makes it easy to create Java enterprise applications. It provides everything you need to embrace the Java language in an enterprise environment, with support for Groovy and Kotlin as alternative languages on the JVM, and with the flexibility to create many kinds of architectures depending on an application’s needs. As of Spring Framework 5.0, Spring requires JDK 8+ (Java SE 8+) and provides out-of-the-box support for JDK 9 already.

Spring可以轻松创建Java企业应用程序。 它提供了在企业环境中支持Java语言所需的一切,并支持Groovy和Kotlin作为JVM上的替代语言,并可根据应用程序的需求灵活地创建多种体系结构。 从Spring Framework 5.0开始,Spring需要JDK 8+(Java SE 8+),并且已经为JDK 9提供了开箱即用的支持。

Spring supports a wide range of application scenarios. In a large enterprise, applications often exist for a long time and have to run on a JDK and application server whose upgrade cycle is beyond developer control. Others may run as a single jar with the server embedded, possibly in a cloud environment. Yet others may be standalone applications (such as batch or integration workloads) that do not need a server.

Spring支持广泛的应用场景。 在大型企业中,应用程序通常存在很长时间,并且必须在升级周期超出开发人员控制的JDK和应用程序服务器上运行。 其他人可能会将嵌入式服务器作为单个jar运行,可能在云环境中运行。 而另一些可能是不需要服务器的独立应用程序(如批处理或集成工作负载)。

Spring is open source. It has a large and active community that provides continuous feedback based on a diverse range of real-world use cases. This has helped Spring to successfully evolve over a very long time.

Spring是开源的。 它拥有一个庞大而活跃的社区,可根据各种实际用例提供持续的反馈。 这有助于Spring在很长一段时间内成功发展。

1. What We Mean by "Spring" 我们所说的“Spring”

The term "Spring" means different things in different contexts. It can be used to refer to the Spring Framework project itself, which is where it all started. Over time, other Spring projects have been built on top of the Spring Framework. Most often, when people say "Spring", they mean the entire family of projects. This reference documentation focuses on the foundation: the Spring Framework itself.

“Spring”一词在不同情况下意味着不同的事物。 它可以用来引用Spring Framework项目本身,这是它开始的地方。 随着时间的推移,其他Spring项目已经建立在Spring框架之上。 大多数情况下,当人们说“Spring”时,他们指的是整个项目系列。 本参考文档重点介绍基础:Spring框架本身。

The Spring Framework is divided into modules. Applications can choose which modules they need. At the heart are the modules of the core container, including a configuration model and a dependency injection mechanism. Beyond that, the Spring Framework provides foundational support for different application architectures, including messaging, transactional data and persistence, and web. It also includes the Servlet-based Spring MVC web framework and, in parallel, the Spring WebFlux reactive web framework.

Spring框架分为几个模块。 应用程序可以选择他们需要的模块。 核心是核心容器的模块,包括配置模型和依赖注入机制。 除此之外,Spring框架为不同的应用程序体系结构提供了基础支持,包括消息传递,事务数据和持久性以及Web。 它还包括基于Servlet的Spring MVC Web框架以及Spring WebFlux反应式Web框架。

A note about modules: Spring’s framework jars allow for deployment to JDK 9’s module path ("Jigsaw"). For use in Jigsaw-enabled applications, the Spring Framework 5 jars come with "Automatic-Module-Name" manifest entries which define stable language-level module names ("spring.core", "spring.context" etc) independent from jar artifact names (the jars follow the same naming pattern with "-" instead of ".", e.g. "spring-core" and "spring-context"). Of course, Spring’s framework jars keep working fine on the classpath on both JDK 8 and 9.

关于模块的注意事项:Spring的框架jar允许部署到JDK 9的模块路径(“Jigsaw”)。 为了在启用Jigsaw的应用程序中使用,Spring Framework 5 jars带有“Automatic-Module-Name”清单条目,它定义了独立于jar伪影的稳定语言级别模块名称(“spring.core”,“spring.context”等) 名称(罐子遵循与“ - ”相同的命名模式,而不是“.”,例如“spring-core”和“spring-context”)。 当然,Spring的框架jar在JDK 8和9的classpath上都能正常工作。

2. History of Spring and the Spring Framework. Spring框架的历史

Spring came into being in 2003 as a response to the complexity of the early J2EE specifications. While some consider Java EE and Spring to be in competition, Spring is, in fact, complementary to Java EE. The Spring programming model does not embrace the Java EE platform specification; rather, it integrates with carefully selected individual specifications from the EE umbrella:

Spring于2003年应运而生,以应对早期J2EE规范的复杂性。 虽然有人认为Java EE和Spring竞争激烈,但Spring实际上是对Java EE的补充。 Spring编程模型不支持Java EE平台规范; 相反,它集成了精心挑选的EE保护伞个人规格:

The Spring Framework also supports the Dependency Injection (JSR 330) and Common Annotations (JSR 250) specifications, which application developers may choose to use instead of the Spring-specific mechanisms provided by the Spring Framework.

Spring框架还支持依赖注入(JSR 330)和Common Annotations(JSR 250)规范,应用程序开发人员可以选择使用这些规范来代替Spring框架提供的Spring特定机制。

As of Spring Framework 5.0, Spring requires the Java EE 7 level (e.g. Servlet 3.1+, JPA 2.1+) as a minimum - while at the same time providing out-of-the-box integration with newer APIs at the Java EE 8 level (e.g. Servlet 4.0, JSON Binding API) when encountered at runtime. This keeps Spring fully compatible with e.g. Tomcat 8 and 9, WebSphere 9, and JBoss EAP 7.

从Spring Framework 5.0开始,Spring需要Java EE 7级别(例如Servlet 3.1+,JPA 2.1+)至少 - 同时在Java EE 8级别提供开箱即用的新API集成 (例如Servlet 4.0,JSON绑定API)在运行时遇到。 这使Spring与例如 Tomcat 8和9,WebSphere 9和JBoss EAP 7。

Over time, the role of Java EE in application development has evolved. In the early days of Java EE and Spring, applications were created to be deployed to an application server. Today, with the help of Spring Boot, applications are created in a devops- and cloud-friendly way, with the Servlet container embedded and trivial to change. As of Spring Framework 5, a WebFlux application does not even use the Servlet API directly and can run on servers (such as Netty) that are not Servlet containers.

随着时间的推移,Java EE在应用程序开发中的作用已经发生了变化。 在Java EE和Spring的早期阶段,创建应用程序以部署到应用程序服务器。 今天,在Spring Boot的帮助下,应用程序以易于云计算和云计算的方式创建,并且嵌入了Servlet容器并且可以轻松更改。 从Spring Framework 5开始,WebFlux应用程序甚至不直接使用Servlet API,而是可以在不是Servlet容器的服务器(如Netty)上运行。

Spring continues to innovate and to evolve. Beyond the Spring Framework, there are other projects, such as Spring Boot, Spring Security, Spring Data, Spring Cloud, Spring Batch, among others. It’s important to remember that each project has its own source code repository, issue tracker, and release cadence. See spring.io/projects for the complete list of Spring projects.

Spring不断创新并不断发展。 除了Spring框架之外,还有其他项目,比如Spring Boot,Spring Security,Spring Data,Spring Cloud,Spring Batch等等。 重要的是要记住,每个项目都有自己的源代码库,问题跟踪器和释放节奏。 有关Spring项目的完整列表,请参阅spring.io/projects。

3. Design Philosophy 设计理念

When you learn about a framework, it’s important to know not only what it does but what principles it follows. Here are the guiding principles of the Spring Framework:

当你了解一个框架时,重要的是不仅要知道它的功能,还要知道它遵循的原则。 以下是Spring框架的指导原则:

  • Provide choice at every level. Spring lets you defer design decisions as late as possible. For example, you can switch persistence providers through configuration without changing your code. The same is true for many other infrastructure concerns and integration with third-party APIs.
  • 在每个级别提供选择。 Spring允许您尽可能迟地推迟设计决策。例如,您可以通过配置切换持久性提供程序,而无需更改代码。许多其他基础架构问题和与第三方API的集成也是如此。

  • Accommodate diverse perspectives. Spring embraces flexibility and is not opinionated about how things should be done. It supports a wide range of application needs with different perspectives.

-适应不同的观点。春天拥抱灵活性,并没有对如何完成事情持有自己的看法。它以不同的视角支持各种应用需求。

  • Maintain strong backward compatibility. Spring’s evolution has been carefully managed to force few breaking changes between versions. Spring supports a carefully chosen range of JDK versions and third-party libraries to facilitate maintenance of applications and libraries that depend on Spring.
  • 保持强大的后向兼容性。 Spring的演化经过精心设计,几乎不会在版本之间发生重大变化。 Spring支持精心挑选的一系列JDK版本和第三方库,以方便维护依赖于Spring的应用程序和库。

  • Care about API design. The Spring team puts a lot of thought and time into making APIs that are intuitive and that hold up across many versions and many years.

-关心API设计。 Spring团队花费了大量的精力和时间来制作直观的API,并支持多种版本和多年。

  • Set high standards for code quality. The Spring Framework puts a strong emphasis on meaningful, current, and accurate Javadoc. It is one of very few projects that can claim clean code structure with no circular dependencies between packages.
  • 为代码质量设定高标准。 Spring框架强调有意义,最新,准确的Javadoc。它是少数几个可以声明干净的代码结构的程序之一,它们之间没有循环依赖关系。

4. Feedback and Contributions 反馈和贡献

For how-to questions or diagnosing or debugging issues, we suggest using StackOverflow, and we have a questions page that lists the suggested tags to use. If you’re fairly certain that there is a problem in the Spring Framework or would like to suggest a feature, please use the JIRA issue tracker.

对于操作方法问题或诊断或调试问题,我们建议使用StackOverflow,并且我们有一个问题页面列出了要使用的建议标签。 如果您确信Spring框架存在问题或者想要推荐一个功能,请使用JIRA问题跟踪。

If you have a solution in mind or a suggested fix, you can submit a pull request on Github. However, please keep in mind that, for all but the most trivial issues, we expect a ticket to be filed in the issue tracker, where discussions take place and leave a record for future reference.

如果你有一个解决方案或建议修复,你可以在Github上提交一个pull请求。 但是,请记住,除了最琐碎的问题外,我们希望在问题跟踪器中提交一张票据,在那里进行讨论并留下备案以备将来参考。

For more details see the guidelines at the CONTRIBUTING, top-level project page.

有关更多详细信息,请参阅CONTRIBUTING顶级项目页面上的指导。

5. Getting Started 入门

If you are just getting started with Spring, you may want to begin using the Spring Framework by creating a Spring Boot-based application. Spring Boot provides a quick (and opinionated) way to create a production-ready Spring-based application. It is based on the Spring Framework, favors convention over configuration, and is designed to get you up and running as quickly as possible.

如果您刚刚开始使用Spring,您可能希望通过创建基于Spring Boot的应用程序来开始使用Spring Framework。 Spring Boot提供了一种快速(并且自以为是)的方式来创建一个生产就绪的基于Spring的应用程序。 它基于Spring Framework,支持惯例而不是配置,并且旨在让您尽快启动并运行。

You can use start.spring.io to generate a basic project or follow one of the "Getting Started" guides, such as Getting Started Building a RESTful Web Service. As well as being easier to digest, these guides are very task focused, and most of them are based on Spring Boot. They also cover other projects from the Spring portfolio that you might want to consider when solving a particular problem.

您可以使用start.spring.io生成一个基本项目,或者按照“入门”指南之一,例如构建RESTful Web服务入门。 除了易于消化外,这些指南非常专注于任务,其中大部分都基于Spring Boot。 他们还涵盖了您在解决特定问题时可能需要考虑的Spring组合中的其他项目。

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏pangguoming

Spring Boot集成JasperReports生成PDF文档

由于工作需要,要实现后端根据模板动态填充数据生成PDF文档,通过技术选型,使用Ireport5.6来设计模板,结合JasperReports5.6工具库来调用渲...

1.2K7
来自专栏一个会写诗的程序员的博客

Spring Reactor 项目核心库Reactor Core

Non-Blocking Reactive Streams Foundation for the JVM both implementing a Reactiv...

2102
来自专栏落花落雨不落叶

canvas画简单电路图

58511
来自专栏闻道于事

js登录滑动验证,不滑动无法登陆

js的判断这里是根据滑块的位置进行判断,应该是用一个flag判断 <%@ page language="java" contentType="text/html...

6608
来自专栏Ceph对象存储方案

Luminous版本PG 分布调优

Luminous版本开始新增的balancer模块在PG分布优化方面效果非常明显,操作也非常简便,强烈推荐各位在集群上线之前进行这一操作,能够极大的提升整个集群...

3035
来自专栏魂祭心

原 canvas绘制clock

4014
来自专栏芋道源码1024

熔断器 Hystrix 源码解析 —— 断路器 HystrixCircuitBreaker

本文主要基于 Hystrix 1.5.X 版本 1. 概述 2. HystrixCircuitBreaker 3. HystrixCircuitBreaker....

5267
来自专栏陈仁松博客

ASP.NET Core 'Microsoft.Win32.Registry' 错误修复

今天在发布Asp.net Core应用到Azure的时候出现错误InvalidOperationException: Cannot find compilati...

4798
来自专栏hbbliyong

WPF Trigger for IsSelected in a DataTemplate for ListBox items

<DataTemplate DataType="{x:Type vm:HeaderSlugViewModel}"> <vw:HeaderSlug...

4054
来自专栏跟着阿笨一起玩NET

c#实现打印功能

2612

扫码关注云+社区