Skip to content

Commit b124066

Browse files
author
Phillip Webb
committed
Add What's new in 4.0 to reference documentation
Update the reference documentation with "What's new in Spring 4.0".
1 parent 309fe9c commit b124066

File tree

2 files changed

+189
-0
lines changed

2 files changed

+189
-0
lines changed

src/asciidoc/appendix.adoc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@
55

66

77

8+
[[migration-4.0]]
9+
== Migrating to Spring Framework 4.0
10+
Migration guides for upgrading from previous releases of the Spring Framework are now
11+
provided as a Wiki page. For details please refer to
12+
https://github.com/spring-projects/spring-framework/wiki/Migrating-from-earlier-versions-of-the-spring-framework
13+
14+
15+
16+
17+
818
[[classic-spring]]
919
== Classic Spring Usage
1020
This appendix discusses some classic Spring usage patterns as a reference for developers

src/asciidoc/index.adoc

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,185 @@ the exact version and feature set of the container.
744744

745745

746746

747+
[[spring-whats-new]]
748+
= What's New in Spring Framework 4.x
749+
750+
751+
752+
753+
[[new-in-4.0]]
754+
== New Features and Enhancements in Spring Framework 4.0
755+
The Spring Framework was first released in 2004, since then there have been only a
756+
few major revisions: Spring 2.0 provided cleaner XML support and improved AOP; Spring 2.5
757+
embraced annotation-driven configuration; Spring 3.0 added Java 5 features, such as
758+
generics and java-based `@Configuration`.
759+
760+
Version 4.0 is the latest major release of the Spring Framework and the first to fully
761+
support Java 8 features. You can still use Spring with older versions of Java, however,
762+
the minimum requirement has now been raised to Java SE 6. We have also taken the
763+
opportunity of a major release to remove many deprecated classes and methods from the
764+
previous version.
765+
766+
A https://github.com/spring-projects/spring-framework/wiki/Migrating-from-earlier-versions-of-the-spring-framework[migration guide for upgrading to Spring 4.0]
767+
is available on the https://github.com/spring-projects/spring-framework/wiki[Spring Framework GitHub Wiki].
768+
769+
770+
771+
=== Improved Getting Started Experience
772+
The new http://spring.io[spring.io] website provides a whole series of
773+
http://spring.io/guides["Getting Started"] guides to help you learn Spring. You
774+
can read more about the guides in the <<overview-getting-started-with-spring>> section
775+
in this document. The new website also provides a comprehensive overview of the many
776+
additional projects that are released under the Spring umbrella.
777+
778+
If you are a Maven user you may also be interested in the helpful
779+
<<overview-maven-bom,bill of materials>> POM file that is now published with each Spring
780+
Framework release.
781+
782+
783+
784+
785+
=== Removed Deprecated Packages and Methods
786+
All deprecated packages, and many deprecated classes and methods have been removed with
787+
version 4.0. If you are upgrading from a previous release of Spring, you should ensure
788+
that you have fixed any deprecated calls that you were making.
789+
790+
For a complete set of changes, check out the
791+
http://docs.spring.io/spring-framework/docs/3.2.4.RELEASE_to_4.0.0.RELEASE/[API
792+
Differences Report].
793+
794+
795+
796+
797+
=== Java 8
798+
Spring Framework 4.0 provides support for several Java 8 features. You can make use of
799+
__lambda expressions__ and __method references__ with Spring's callback interfaces. There
800+
is first class support for `java.time` (http://jcp.org/en/jsr/detail?id=310[JSR-310]) and
801+
several existing annotations have been retrofitted as `@Repeatable`. You can also use
802+
Java 8's parameter name discovery as an alternative to compiling your code with debug
803+
information enabled.
804+
805+
Spring remains compatible with older versions of Java, 6.0 and above are fully
806+
supported.
807+
808+
809+
810+
811+
=== Java EE 6
812+
Java EE version 6 or above is now considered the baseline for Spring Framework 4.0. With
813+
the JPA 2.0 and Servlet 3.0 specifications being of particular relevance. In order to
814+
remain compatible with Google App Engine, it is possible to deploy a Spring application
815+
into a Servlet 2.5 environment, however, Servlet 3.0+ is recommended when at all possible.
816+
817+
If you are a WebSphere 7 user, be sure install the JPA 2.0 feature pack.
818+
819+
820+
821+
822+
=== WebSocket, SockJS, and STOMP Messaging
823+
A new `spring-websocket` module provides comprehensive support for WebSocket-based,
824+
two-way communication between client and server in web applications. It is compatible with
825+
http://jcp.org/en/jsr/detail?id=356[JSR-356], the Java WebSocket API, and in addition
826+
provides SockJS-based fallback options (i.e. WebSocket emulation) for use in browsers
827+
that don't yet support the WebSocket protocol (e.g. IE < 10).
828+
829+
A new `spring-messaging` module adds support for STOMP as the WebSocket sub-protocol
830+
to use in applications along with an annotation programming model for routing and
831+
processing STOMP messages from WebSocket clients. As a result an `@Controller`
832+
can now contain both `@RequestMapping` and `@MessageMapping` methods for handling
833+
HTTP requests and messages from WebSocket-connected clients. The new `spring-messaging`
834+
module also contains key abstractions from the
835+
http://projects.spring.io/spring-integration/[Spring Integration] project such as
836+
`Message`, `MessageChannel`, `MessageHandler` and others to serve as
837+
a foundation for messaging applications.
838+
839+
For more details including a more thorough introduction see the <<websocket>> section.
840+
841+
842+
843+
844+
=== Core Container Improvements
845+
There have been several general improvements to the core IoC container:
846+
847+
* Spring now treats <<beans-generics-as-qualifiers,__generic types__ as a form of
848+
__qualifier__>> when injecting Beans. For example, if you are using a Spring Data
849+
`Repository` you can now easily inject a specific implementation:
850+
`@Autowired Repository<Customer> customerRepository`.
851+
* If you use Spring's meta-annotation support, you can now develop custom annotations that
852+
<<beans-meta-annotations,expose specific attributes from the source annotation>>.
853+
* Beans can now be `Ordered` when they are <<beans-autowired-annotation,autowired into
854+
lists and arrays>>. Both the `@Ordered` annotation and `Ordered` interface are
855+
supported.
856+
* A generalized model for <<beans-java-conditional,conditionally filtering beans>> has
857+
been added via the `@Conditional` annotation. This is similar to `@Profile` but allow
858+
user-defined strategies to be developed.
859+
* <<aop-pfb-proxy-types,CGLIB-based proxy classes>> no longer require a default
860+
constructor. Support is provided via the http://code.google.com/p/objenesis/[objenesis]
861+
library which is repackaged __inline__ and distributed as part of the Spring Framework.
862+
* The `@Lazy` annotation can now be used on injection points, as well as `@Bean`
863+
definitions.
864+
* The <<beans-java-bean-description,`@Description` annotation has been added>> for
865+
developers using Java-based configuration.
866+
* It is now possible to specify a time zone with the `@Scheduled` annotation.
867+
868+
869+
870+
871+
=== Web Improvements
872+
Deployment to Servlet 2.5 servers remains an option, but Spring Framework 4.0 is now
873+
focused primarily on Servlet 3.0+ environments. If you are using the
874+
<<spring-mvc-test-framework,Spring MVC Test Framework>> you
875+
will need to ensure that a Servlet 3.0 compatible JAR is in your __test classpath__.
876+
877+
In addition to the WebSocket support mentioned earlier, the following general improvements
878+
have been made to Spring's Web modules:
879+
880+
* You can use <<mvc-ann-restcontroller,the new `@RestController` annotation>> with Spring
881+
MVC applications, removing the need to add `@ResponseBody` to each of your
882+
`@RequestMapping` methods.
883+
* The `AsyncRestTemplate` class has been added, <<rest-async-resttemplate,allowing
884+
non-blocking asynchronous support>> when developing REST clients.
885+
* Spring now offers <<mvc-timezone,comprehensive timezone support>> when developing
886+
Spring MVC applications.
887+
888+
889+
=== Groovy DSL Support
890+
With Spring Framework 4.0 it is now possible to define external bean configuration using
891+
a Groovy DSL. This is similar in concept to using XML bean definitions, but allows for
892+
a much more concise syntax. Using Groovy also allows you to easily embed bean definitions
893+
directly in your code. For example:
894+
895+
[source,groovy,indent=0]
896+
[subs="verbatim,quotes"]
897+
----
898+
def reader = new GroovyBeanDefinitionReader(myApplicationContext)
899+
reader.beans {
900+
dataSource(BasicDataSource) {
901+
driverClassName = "org.hsqldb.jdbcDriver"
902+
url = "jdbc:hsqldb:mem:grailsDB"
903+
username = "sa"
904+
password = ""
905+
settings = [mynew:"setting"]
906+
}
907+
sessionFactory(SessionFactory) {
908+
dataSource = dataSource
909+
}
910+
myService(MyService) {
911+
nestedBean = { AnotherBean bean ->
912+
dataSource = dataSource
913+
}
914+
}
915+
}
916+
----
917+
918+
For more information consult the `GroovyBeanDefinitionReader`
919+
{javadoc-baseurl}/org/springframework/beans/factory/groovy/GroovyBeanDefinitionReader.html[Javadoc].
920+
921+
922+
923+
924+
925+
747926

748927
[[spring-core]]
749928
= Core Technologies

0 commit comments

Comments
 (0)