You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
160 lines
8.8 KiB
160 lines
8.8 KiB
7 years ago
|
[[overview]]
|
||
|
= Spring Framework Overview
|
||
7 years ago
|
:docinfo1:
|
||
7 years ago
|
|
||
7 years ago
|
Spring makes it easy to create Java enterprise applications. It provides everything you
|
||
7 years ago
|
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
|
||
2 years ago
|
kinds of architectures depending on an application's needs. As of Spring Framework 6.0,
|
||
|
Spring requires Java 17+.
|
||
10 years ago
|
|
||
7 years ago
|
Spring supports a wide range of application scenarios. In a large enterprise, applications
|
||
7 years ago
|
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.
|
||
8 years ago
|
|
||
7 years ago
|
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.
|
||
8 years ago
|
|
||
7 years ago
|
|
||
|
|
||
|
|
||
7 years ago
|
[[overview-spring]]
|
||
7 years ago
|
== What We Mean by "Spring"
|
||
10 years ago
|
|
||
7 years ago
|
The term "Spring" means different things in different contexts. It can be used to refer to
|
||
7 years ago
|
the Spring Framework project itself, which is where it all started. Over time, other Spring
|
||
7 years ago
|
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.
|
||
10 years ago
|
|
||
7 years ago
|
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
|
||
7 years ago
|
persistence, and web. It also includes the Servlet-based Spring MVC web framework and, in
|
||
7 years ago
|
parallel, the Spring WebFlux reactive web framework.
|
||
10 years ago
|
|
||
7 years ago
|
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
|
||
3 years ago
|
("spring.core", "spring.context", etc.) independent from jar artifact names (the jars follow
|
||
7 years ago
|
the same naming pattern with "-" instead of ".", e.g. "spring-core" and "spring-context").
|
||
6 years ago
|
Of course, Spring's framework jars keep working fine on the classpath on both JDK 8 and 9+.
|
||
7 years ago
|
|
||
7 years ago
|
|
||
|
|
||
|
|
||
7 years ago
|
[[overview-history]]
|
||
7 years ago
|
== History of Spring and the Spring Framework
|
||
10 years ago
|
|
||
7 years ago
|
Spring came into being in 2003 as a response to the complexity of the early
|
||
|
https://en.wikipedia.org/wiki/Java_Platform,_Enterprise_Edition[J2EE] specifications.
|
||
3 years ago
|
While some consider Java EE and its modern-day successor Jakarta EE to be in
|
||
|
competition with Spring, they are in fact complementary. The Spring programming
|
||
|
model does not embrace the Jakarta EE platform specification; rather, it integrates
|
||
|
with carefully selected individual specifications from the traditional EE umbrella:
|
||
10 years ago
|
|
||
7 years ago
|
* Servlet API (https://jcp.org/en/jsr/detail?id=340[JSR 340])
|
||
7 years ago
|
* WebSocket API (https://www.jcp.org/en/jsr/detail?id=356[JSR 356])
|
||
|
* Concurrency Utilities (https://www.jcp.org/en/jsr/detail?id=236[JSR 236])
|
||
7 years ago
|
* JSON Binding API (https://jcp.org/en/jsr/detail?id=367[JSR 367])
|
||
|
* Bean Validation (https://jcp.org/en/jsr/detail?id=303[JSR 303])
|
||
7 years ago
|
* JPA (https://jcp.org/en/jsr/detail?id=338[JSR 338])
|
||
|
* JMS (https://jcp.org/en/jsr/detail?id=914[JSR 914])
|
||
|
* as well as JTA/JCA setups for transaction coordination, if necessary.
|
||
10 years ago
|
|
||
7 years ago
|
The Spring Framework also supports the Dependency Injection
|
||
|
(https://www.jcp.org/en/jsr/detail?id=330[JSR 330]) and Common Annotations
|
||
3 years ago
|
(https://jcp.org/en/jsr/detail?id=250[JSR 250]) specifications, which application
|
||
|
developers may choose to use instead of the Spring-specific mechanisms provided
|
||
|
by the Spring Framework. Originally, those were based on common `javax` packages.
|
||
|
|
||
|
As of Spring Framework 6.0, Spring has been upgraded to the Jakarta EE 9 level
|
||
|
(e.g. Servlet 5.0+, JPA 3.0+), based on the `jakarta` namespace instead of the
|
||
2 years ago
|
traditional `javax` packages. With EE 9 as the minimum and EE 10 supported already,
|
||
|
Spring is prepared to provide out-of-the-box support for the further evolution of
|
||
|
the Jakarta EE APIs. Spring Framework 6.0 is fully compatible with Tomcat 10.1,
|
||
|
Jetty 11 and Undertow 2.3 as web servers, and also with Hibernate ORM 6.1.
|
||
3 years ago
|
|
||
|
Over time, the role of Java/Jakarta EE in application development has evolved. In the
|
||
|
early days of J2EE 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
|
||
7 years ago
|
and can run on servers (such as Netty) that are not Servlet containers.
|
||
10 years ago
|
|
||
7 years ago
|
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 https://spring.io/projects[spring.io/projects] for
|
||
|
the complete list of Spring projects.
|
||
10 years ago
|
|
||
7 years ago
|
|
||
|
|
||
|
|
||
7 years ago
|
[[overview-philosophy]]
|
||
7 years ago
|
== Design Philosophy
|
||
10 years ago
|
|
||
7 years ago
|
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
|
||
6 years ago
|
meaningful, current, and accurate javadoc. It is one of very few projects that can claim
|
||
7 years ago
|
clean code structure with no circular dependencies between packages.
|
||
10 years ago
|
|
||
7 years ago
|
|
||
|
|
||
|
|
||
7 years ago
|
[[overview-feedback]]
|
||
7 years ago
|
== Feedback and Contributions
|
||
10 years ago
|
|
||
4 years ago
|
For how-to questions or diagnosing or debugging issues, we suggest using Stack Overflow. Click
|
||
3 years ago
|
https://stackoverflow.com/questions/tagged/spring+or+spring-mvc+or+spring-aop+or+spring-jdbc+or+spring-r2dbc+or+spring-transactions+or+spring-annotations+or+spring-jms+or+spring-el+or+spring-test+or+spring+or+spring-orm+or+spring-jmx+or+spring-cache+or+spring-webflux+or+spring-rsocket?tab=Newest[here]
|
||
4 years ago
|
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 https://github.com/spring-projects/spring-framework/issues[GitHub Issues].
|
||
10 years ago
|
|
||
7 years ago
|
If you have a solution in mind or a suggested fix, you can submit a pull request on
|
||
|
https://github.com/spring-projects/spring-framework[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.
|
||
10 years ago
|
|
||
4 years ago
|
For more details see the guidelines at the {spring-framework-main-code}/CONTRIBUTING.md[CONTRIBUTING],
|
||
7 years ago
|
top-level project page.
|
||
10 years ago
|
|
||
7 years ago
|
|
||
|
|
||
|
|
||
7 years ago
|
[[overview-getting-started]]
|
||
7 years ago
|
== Getting Started
|
||
10 years ago
|
|
||
7 years ago
|
If you are just getting started with Spring, you may want to begin using the Spring
|
||
6 years ago
|
Framework by creating a https://projects.spring.io/spring-boot/[Spring Boot]-based
|
||
7 years ago
|
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.
|
||
|
|
||
6 years ago
|
You can use https://start.spring.io/[start.spring.io] to generate a basic project or follow
|
||
7 years ago
|
one of the https://spring.io/guides["Getting Started" guides], such as
|
||
|
https://spring.io/guides/gs/rest-service/[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.
|