Spring Framework Documentation - overview

原文:https://docs.spring.io/spring-framework/docs/current/reference/html/overview.html#overview

注:Spring 的设计哲学我觉得真的很棒,参考本文章节3。

spring version : 5.3.9

Spring使创建Java企业应用程序变得容易。它提供了在企业环境中使用Java语言所需的一切,支持Groovy和Kotlin作为JVM上的可选语言,并具有很高的灵活性,使之可以根据应用的需要创建多种程序结构。从SpringFramework5.1开始,Spring要求JDK8+(JavaSE8+),并为JDK11LTS提供开箱即用的支持。建议最低使用JavaSE8Update60,但通常建议使用最新的补丁版本。

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

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是开源的。他拥有一个巨大的,活跃的社区,可以提供不间断的,基于真实使用场景的反馈。这使得Spring长久以来获得成功的进化。

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.

1. 我们对Spring的理解 What We Mean by "Spring"

Spring 在不同的上下文有不同的含义。它可以被用来指代 Spring Framework 项目本身,Spring Framework 是一切开始的地方。渐渐地,其他的Spring 项目在Spring Framework上面构建起来。大多时候,当人们在说到Spring的时候,他们指的是整个Spring项目家族。本文集中在基础层面:Spring Framework 本身。

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 Framework 可以分为多个模块。应用可选他们需要的模块使用。最核心的模块是核心容器(core container),包括配置模块,依赖注入机制。除了这些,Spring Framework 提供了对不同结构的应用的基本支持,包括消息,事务,持久化,web等。他还提供了基于Servlet 规范的Spring MVC web 框架,并且,还支持reactive 模式的 WebFlux。

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的框架JAR允许部署到JDK 9的模块路径(“Jigsaw”)。为了在支持Jigsaw的应用程序中使用,Spring Framework 5 jar附带了“Automatic Module Name”清单条目,这些条目定义了稳定的语言级模块名(“Spring.core”、“Spring.context”等),独立于jar工件名(jar遵循相同的命名模式,用“-”代替“.”,例如“Spring core”和“Spring context”)。当然,Spring的框架JAR在JDK 8和9+上的类路径上都能正常工作。

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+.

2. Spring和Spring Framework 的历史 History of Spring and the Spring Framework

Spring于2003年诞生,作为对早期J2EE规范复杂性的响应。虽然有些人认为java EE和Spring将处于竞争状态,但实际上,Spring是java EE的补充。Spring编程模型不包含JavaEE平台规范;相反,它与精心挑选的EE 伞结构中的单个规范集成:

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框架还支持依赖项注入(JSR330)和通用注解(JSR250)规范,应用程序开发人员可以选择使用这些规范来代替Spring框架提供的Spring特定机制。

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 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完全兼容。

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.

随着时间的推移,javaee在应用程序开发中的角色已经发生了变化。在JavaEE和Spring的早期,创建应用程序是为了部署到应用服务器。今天,在SpringBoot的帮助下,应用程序是以devops和云友好的方式创建的,嵌入了Servlet容器,可以进行简单的更改。从SpringFramework5开始,WebFlux应用程序不直接使用Servlet API,可以在非Servlet容器的服务器(如Netty)上运行。

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.

Spring继续创新和发展。除了Spring框架之外,还有其他项目,如Spring Boot、Spring Security、SpringCloud、Spring Batch等。重要的是,每个项目都有自己的源代码存储库、问题跟踪和发布j节奏。有关spring项目的完整列表,请参见 spring 官网: spring.io/projects。

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.

3. 设计哲学 Design Philosophy

当你在学习一个框架的时候,重要的不仅仅是他做了什么,而是他遵循的原则是什么。这里提供了一些指导Spring Framework的原则:

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 可以让你尽量推迟设计的讨论。比如,你可以在不修改代码只修改配置的情况下进行数据库选型。同样的,许多基础设施和第三方API集成也是这样。

  • 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具有灵活性,对于事情应该如何做并不固执己见。它以不同的视角支持广泛的应用程序需求。

  • 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的发展经过了精心管理,使得版本之间几乎没有突破性的变化。Spring支持一系列精心挑选的JDK版本和第三方库,这使维护依赖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.

  • 关注API的设计。Spring 团队在创建APIs 的时候投入的巨大的精力和时间,这使得APIs更加直观,并且在多年以来的的多个版本中可持续使用。

  • 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.

  • 为代码质量设定高标准。Spring Framework 非常强调有意义、最新和准确的javadoc。它是极少数几个可以声称代码结构干净、包之间没有循环依赖关系的项目之一。

  • 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.

4. 反馈和捐赠 Feedback and Contributions

对于 怎么做的问题,或者是 debug 问题,我们建议使用Stack Overflow。点击 这里 获取使用Stack Overflow的建议列表。如果你确信是Spring Framework的问题,或者提供功能建议,可以使用GitHub Issues

For how-to questions or diagnosing or debugging issues, we suggest using Stack Overflow. Click here for a list of the suggested tags to use on Stack Overflow. 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.

如果你有解决方案或者bug fix建议,你可以在 Github 提交pull request 。不过请注意,除了一些琐碎的小问题,我们希望在问题跟踪程序中提交一份记录单,在那里进行讨论,并留下记录以供将来参考。

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.

更多参考看 CONTRIBUTING

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

5. 准备开干 Getting Started

如果您刚刚开始使用Spring,您可能希望通过创建基于Spring引导的应用程序来开始使用Spring框架。SpringBoot提供了一种快速(自以为正确)的方法来创建一个基于Spring的应用程序。它基于Spring框架,支持约定而非配置,旨在让您尽快启动并运行。

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.

您可以使用  start.spring.io 生成一个基本项目,或者遵循开干指南 ,例如Getting Started Building a RESTful Web Service。这些指南易于理解,专注于任务,而且大多数都基于Spring Boot。它们还涵盖了在解决特定问题时可能需要考虑的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.

Version 5.3.9
Last updated 2021-07-14 06:36:18 UTC

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值