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.1, Spring requires JDK 8+ (Java SE 8+) and provides out-of-the-box support for JDK 11 LTS.
Java SE 8 update 60 is suggested as the minimum patch release for Java 8,but it is generally recommended to use a recent patch release.
Spring使创建Java企业应用程序变得容易。
它提供了在企业环境中使用Java语言所需的一切,支持将Groovy和Kotlin作为JVM上的替代语言,并具有根据应用程序的需要创建多种体系结构的灵活性。
从Spring Framework 5.1开始,Spring需要JDK8+(JavaSE8+),并为JDK11LTS提供开箱即用的支持。
建议将Java SE8u60作为Java8的最低补丁版本,但通常建议使用最新的补丁版本。
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运行,服务器嵌入其中,可能是在云环境中。
然而,其他可能是不需要服务器的独立应用程序(例如批处理或集成工作负载)。
注:企业应用、嵌入服务器的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"
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.
1.我们所说的“Spring”
“Spring”一词在不同的语境中有不同的含义。
它可以用来引用Spring Framework项目本身,这是它全部开始的地方(个人理解:Spring Framework是其他Spring项目的基础)。
随着时间的推移,其他Spring项目已经建立在Spring Framework之上。
通常,当人们说“Spring”时,他们指的是整个项目家族。
这个参考文档集中于基础:Spring Framework本身。
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 independent from jar artifact names
Of course, Spring’s framework jars keep working fine on the classpath on both JDK 8 and 9+.
关于模块的说明:
Spring的framework jars允许部署到JDK 9的模块路径(“Jigsaw”)。
为了在支持Jigsaw的应用程序中使用,Spring Framework 5 jar附带了“自动模块名”清单条目,这些条目定义了与jar组件名(jar遵循相同的命名模式,使用“-”而不是“.”,例如“spring-core”和“spring-context”)无关的稳定的语言级别模块名称(“Spring.core”、“Spring.context”等)。
当然,Spring的framework jar在JDK 8和9+上的类路径上仍然运行良好。
注:本人没用过JDK 9的Jigsaw,所以不是很理解这段的意思,看了一下spring-context-5.2.5.RELEASE.jar中MANIFEST.MF文件,截图如下
2. History of Spring and the Spring Framework
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:
Servlet API (JSR 340)
WebSocket API (JSR 356)
Concurrency Utilities (JSR 236)
JSON Binding API (JSR 367)
Bean Validation (JSR 303)
JPA (JSR 338)
JMS (JSR 914)
as well as JTA/JCA setups for transaction coordination, if necessary.(以及必要时用于事务协调的JTA / JCA设置)
2.Spring与Spring Framework的历史
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 Framework也支持依赖注入(JSR 330 )和通用的注解(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(如Servlet3.1+,JPA2.1+),同时在运行时提供与Java EE 8 的新API(如Servlet4.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引导的帮助下,应用程序以一种devops和云友好的方式创建,嵌入了Servlet容器,而且更改起来很简单。
从Spring Framework 5开始,WebFlux应用程序甚至不直接使用ServletAPI,可以在非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 Framework之外,还有其他项目,比如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:
3.设计理念
当你了解一个框架时,不仅要知道它做什么,而且要知道它遵循什么原则。以下是Spring Framework的指导原则:
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.
适应不同的观点。
Spring具有灵活性,对事情应该如何做并不固执己见。
它支持具有不同视角的广泛应用程序需求。
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 Framework着重于一个易懂,具有时效性,准确的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 GitHub Issues.
4.反馈和贡献
关于如何提出问题,诊断,调试问题,我们建议使用StackOverflow,我们也提供一个问题页面,其中列出了一些问题标签可以点击查看。
如果你有相当的把握发现了Spring Framework中有某个问题,或者有好的建议,请使用GitHub Issues。
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.
For more details see the guidelines at the CONTRIBUTING, top-level project page.
如果你有好的解决方案或建议,你可以在Github提交一个pull request。
然而,需要记住的是,除了无关紧要的问题外,我们希望能够在issue tracker中讨论,留下记录以供将来参考。
有关更多详细信息,请参见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.
5.入门指南
如果您刚刚开始使用Spring,那么您可能希望通过创建一个基于Spring Boot的应用程序来开始使用Spring Framework。
Spring Boot提供了一种快速(且固执己见)的方法来创建可用于生产的基于Spring的应用程序。
它基于Spring框架,支持约定优于配置,旨在让您尽可能快地启动和运行。
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生成一个基本项目,也可以遵循“Getting Started”指南之一,例如Getting Started Building a RESTful Web Service。
这些指南不仅易于理解,而且非常注重任务,而且大多数都基于Spring Boot。
它们还涵盖了Spring产品组合中的其他项目,您在解决特定问题时可能会考虑这些项目。
20200330