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 条评论
登录 后参与评论

相关文章

来自专栏GIS讲堂

eclipse中建geoserver源码

概述:本文讲述的是在eclipse中如何构建geoserver源码工程,其中涉及到了jdk,github,marven等。

1353
来自专栏ml

flume安装及配置介绍(二)

注: 环境: skylin-linux Flume的下载方式:   wget http://www.apache.org/dyn/closer.lua/flu...

33711
来自专栏玩转JavaEE

推荐几个Spring Cloud学习资料

研究Spring Cloud也有一段时间了,手头上有一点收集的资料,分享给小伙伴们学习(公众号不允许外链,所以排版效果不太好,有兴趣的小伙伴点击文末阅读原文)。...

4223
来自专栏杨建荣的学习笔记

巧用shell脚本统计磁盘使用情况(r4笔记第12天)

在系统环境中存在大量的文件时,统计磁盘空间的工作变得尤为重要。 首先是传统的文件统计,通常使用-s选项,但是只能得到一个概要的信息,如果想定位哪些文件消耗的空间...

3097
来自专栏bboysoul

社会工程学信息收集工具(Userrecon)

这个工具最主要的功能就是可以让你在知道用户名的情况下批量去各个社交网站上查找这个用户名的主页,方便收集对象的主页

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

第3讲 Kotlin + Spring Boot 集成 MyBatis 进行数据库层开发【视频教程】《Kotlin + Spring Boot:下一代 Java 服务端开发》系列课程 ——《Kotli

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

Spring BOOT ( 基于Kotlin 编程语言) 使用 Spring WebFlux 实现响应式编程The Spring WebFlux Framework

Spring BOOT ( 基于Kotlin 编程语言) 使用 Spring WebFlux 实现响应式编程

872
来自专栏A周立SpringCloud

Spring Cloud各组件配置属性总结

我们知道,Spring Cloud是个工具集,整合了各种组件。有的组件Spring Cloud是拿来主义,有的组件Spring Cloud又进行了一些增强(例如...

3495
来自专栏杂烩

组件化项目搭建(非专业,无聊的一次尝试)三 原

        现在dao已经独立出去了,办公室里的一部分人员分出去,但还有一些干等着呢。得了,继续弄吧,业务这层,包含的还有控制器这一层,所以直接使用spri...

862
来自专栏杂烩

SSM项目搭建之Spring 原

Spring是一个开源框架,Spring是于2003 年兴起的一个轻量级的Java 开发框架,由Rod Johnson 在其著作Expert One-On-O...

2064

扫码关注云+社区