Spring framework Overview

Spring framework Overview

Version 5.1.3.RELEASE
英文原文地址:
https://docs.spring.io/spring/docs/5.1.3.RELEASE/spring-framework-reference/overview.html#overview

Spring makes it easy to create Java enterprise applications. It provides everything you need to embrace the Java language in an enterprise environment, whth 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企业应用程序。由于支持GroovyKotlin作为JVM上的替代语言,并可以根据应用程序的需要灵活的创建多种体系结构,所以它可以提供了在企业环境开发中使用Java语言所需的一切。从Spring Frame Work5.0开始,Spring需要JDK8,并且已经为JDK9提供了开箱即用的支持。

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 single jar with the server embedded, possibly in 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 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 bean 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 Framwork itself.

术语“Spring” 在不同的环境下,意义也不同。它可以指Spring Framework Project 本身,那是它起源的一个工程。随着时间的推移,其他的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 reactice web framework.

Spring Framework 分为几个模块。 应用程序可以选择他们需要的模块。 core container是核心模块,包括配置模型和依赖注入机制。除此之外, Spring 框架还为不同的应用程序架构提供了基本支持,包括消息传递,事务数据和持久性以及Web。它还包括基于servlet的Spring MVC web框架,以及与之并行的Spring WebFlux活性框架。

A note about modules: Spring’s frmaework jars allow for deployment to JDK 9’s module path(“Jigsaw”).For use in Jigsaw-enabled applications ,the Spirng 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 JDK8 and 9

关于模块的注意事项: Spring的框架jar允许部署JDK 9 的模块路径(“Jigsaw”)。对于在支持jigsaw的应用程序中使用,Spring Framework 5 jar附带了“自动模块名”清单条目,这些条目定义了稳定的语言及模块(“spring.core”,“spring.context” 等等)独立于jar工程名称(jar遵循”-“而不是”.“模式,比如”spring-core“和”spring-context“)。当然,Spring框架的jar可以在JDK8 和JDK9 的类路径上正常工作。

2. History of Spring and the Spring Framework

Spring came into being in 2003 as a response to the complexity of early J2EE specifications. While some consider JavaEE 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.

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框架还支持依赖注入(JSR 330)和公共注释(JSR 250)规范,应用程序开发人员可以选择使用这些规范而不是Spring框架提供的特定于Spring的机制。

从Spring Framework 5.0开始,Spring至少需要Java EE 7级别(例如Servlet 3.1+、JPA 2.1+),同时在运行时遇到新的Java EE 8级别(例如Servlet 4.0、JSON绑定API)时提供开箱即用的集成。这使Spring完全兼容Tomcat 8和Tomcat 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的帮助下,应用程序是以devops和云友好的方式创建的,其中嵌入了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 等其他项目。重要的是要记住每个项目都有自己的源代码库,问题跟踪器,和发版节奏。可以在 www.spring.io/projects 看到完整的Spring项目列表。

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:

  • 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.
  • 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.
  • 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.
  • 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框架所遵循的点

  • 在各个层面提供选择。Spring允许您尽可能晚的推迟设计决策。比如,您可以通过配置切换持久性提供程序,而无需更改代码。许多其他基础架构问题以及与第三方API的集成也是如此。(个人理解为可配置,低耦合)
  • 适应不同的观点。Spring拥有灵活性,它并不认定应该如何做。它以不同的视角支持广泛的应用需求。
  • 保持强大的向后兼容性。Spring的演变经过精心设计,可以在版本之间进行一些重大改变,Spring支持精心挑选的JDK版本和第三方库,以便于维护依赖于Spring的应用程序和库。
  • 关心API设计。 Spring团队投入了大量的思考和时间来制作直观的API,并且可以支持多个版本和多年。
  • 为代码质量设定高标准。 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.

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.

question page: https://spring.io/questions

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.

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.

第四点和第五点比较简单,就不翻译了,直接读原文吧。

第四点大致意思是反馈与贡献,
第五点为如何开始一个spring框架项目:

  1. 官网直接按需生成好集成了相关模块的工程下载 : https://start.spring.io/
  2. Getting Started Building a RESTful Web Service : https://spring.io/guides/gs/rest-service/

猜你喜欢

转载自blog.csdn.net/wan923713277/article/details/85463284
今日推荐