@@ -752,22 +752,22 @@ the exact version and feature set of the container.
752
752
753
753
[[new-in-4.0]]
754
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`.
755
+ The Spring Framework was first released in 2004; since then there have been significant
756
+ major revisions: Spring 2.0 provided XML namespaces and AspectJ support ; Spring 2.5
757
+ embraced annotation-driven configuration; Spring 3.0 introduced a strong Java 5+ foundation
758
+ across the framework codebase, and features such as the Java -based `@Configuration` model .
759
759
760
760
Version 4.0 is the latest major release of the Spring Framework and the first to fully
761
761
support Java 8 features. You can still use Spring with older versions of Java, however,
762
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.
763
+ opportunity of a major release to remove many deprecated classes and methods.
765
764
766
765
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
766
is available on the https://github.com/spring-projects/spring-framework/wiki[Spring Framework GitHub Wiki].
768
767
769
768
770
769
770
+
771
771
=== Improved Getting Started Experience
772
772
The new http://spring.io[spring.io] website provides a whole series of
773
773
http://spring.io/guides["Getting Started"] guides to help you learn Spring. You
@@ -783,66 +783,106 @@ Framework release.
783
783
784
784
785
785
=== Removed Deprecated Packages and Methods
786
- All deprecated packages, and many deprecated classes, methods, and fields have been
787
- removed with version 4.0. If you are upgrading from a previous release of Spring, you
788
- should ensure that you have fixed any deprecated calls that you were making.
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 to outdated APIs .
789
789
790
790
For a complete set of changes, check out the
791
791
http://docs.spring.io/spring-framework/docs/3.2.4.RELEASE_to_4.0.0.RELEASE/[API
792
792
Differences Report].
793
793
794
+ Note that optional third-party dependencies have been raised to a 2010/2011 minimum
795
+ (i.e. Spring 4 generally only supports versions released in late 2010 or later now):
796
+ notably, Hibernate 3.6+, EhCache 2.1+, Quartz 1.8+, Groovy 1.8+, and Joda-Time 2.0+.
797
+ As an exception to the rule, Spring 4 requires the recent Hibernate Validator 4.3+,
798
+ and support for Jackson has been focused on 2.0+ now (with Jackson 1.8/1.9 support
799
+ retained for the time being where Spring 3.2 had it; now just in deprecated form).
800
+
794
801
795
802
796
803
797
- === Java 8
804
+ === Java 8 (as well as 6 and 7)
798
805
Spring Framework 4.0 provides support for several Java 8 features. You can make use of
799
806
__lambda expressions__ and __method references__ with Spring's callback interfaces. There
800
807
is first class support for `java.time` (http://jcp.org/en/jsr/detail?id=310[JSR-310]) and
801
808
several existing annotations have been retrofitted as `@Repeatable`. You can also use
802
809
Java 8's parameter name discovery as an alternative to compiling your code with debug
803
810
information enabled.
804
811
805
- Spring remains compatible with older versions of Java, 6.0 and above are fully
806
- supported.
812
+ Spring remains compatible with older versions of Java and the JDK: Concretely, Java SE 6
813
+ (specifically, a minimum level equivalent to JDK 6 update 10, as released in late 2008)
814
+ and above are still fully supported. However, for newly started development projects
815
+ based on Spring 4, we recommend the use of Java 7 or 8.
807
816
817
+ Note that the Java 8 bytecode level (-target 1.8, as required by -source 1.8) is only
818
+ fully supported as of Spring Framework 4.0. In particular, Spring 3.2 based applications
819
+ need to be compiled with a maximum of Java 7 as the target, even if they happen to be
820
+ deployed onto a Java 8 runtime. Please upgrade to Spring 4 for Java 8 based applications.
808
821
809
822
810
823
811
- === Java EE 6
812
- Java EE version 6 or above is now considered the baseline for Spring Framework 4.0. With
824
+
825
+ === Java EE 6 and 7
826
+ Java EE version 6 or above is now considered the baseline for Spring Framework 4, with
813
827
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.
828
+ remain compatible with Google App Engine and older application servers, it is possible
829
+ to deploy a Spring application into a Servlet 2.5 environment; however, Servlet 3.0+
830
+ is recommended when at all possible.
816
831
817
- If you are a WebSphere 7 user, be sure install the JPA 2.0 feature pack.
832
+ Note: If you are a WebSphere 7 user, be sure install the JPA 2.0 feature pack. On
833
+ WebLogic 10.3.4 or higher, install the JPA 2.0 patch that comes with it. This turns
834
+ both of those server generations into Spring 4 compatible deployment environments.
818
835
836
+ On a more forward-looking note, Spring Framework 4.0 supports the Java EE 7 level of
837
+ applicable specifications now: in particular, JMS 2.0, JTA 1.2, JPA 2.1, Bean Validation
838
+ 1.1, and JSR-236 Concurrency Utilities. As usual, this support focuses on individual
839
+ use of those specifications, e.g. on Tomcat or in standalone environments. However,
840
+ it works equally well when a Spring application is being deployed to a Java EE 7 server.
819
841
842
+ Note that Hibernate 4.3 is a JPA 2.1 provider and therefore only supported as of
843
+ Spring Framework 4.0. The same applies to Hibernate Validator 5.0 as a Bean Validation
844
+ 1.1 provider. Neither of the two are officially supported with Spring Framework 3.2.
820
845
821
846
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
847
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
848
839
- For more details including a more thorough introduction see the <<websocket>> section.
849
+ === Groovy Bean Definition DSL
850
+ With Spring Framework 4.0 it is now possible to define external bean configuration using
851
+ a Groovy DSL. This is similar in concept to using XML bean definitions, but allows for
852
+ a more concise syntax. Using Groovy also allows you to easily embed bean definitions
853
+ directly in your bootstrap code. For example:
854
+
855
+ [source,groovy,indent=0]
856
+ [subs="verbatim,quotes"]
857
+ ----
858
+ def reader = new GroovyBeanDefinitionReader(myApplicationContext)
859
+ reader.beans {
860
+ dataSource(BasicDataSource) {
861
+ driverClassName = "org.hsqldb.jdbcDriver"
862
+ url = "jdbc:hsqldb:mem:grailsDB"
863
+ username = "sa"
864
+ password = ""
865
+ settings = [mynew:"setting"]
866
+ }
867
+ sessionFactory(SessionFactory) {
868
+ dataSource = dataSource
869
+ }
870
+ myService(MyService) {
871
+ nestedBean = { AnotherBean bean ->
872
+ dataSource = dataSource
873
+ }
874
+ }
875
+ }
876
+ ----
877
+
878
+ For more information consult the `GroovyBeanDefinitionReader`
879
+ {javadoc-baseurl}/org/springframework/beans/factory/groovy/GroovyBeanDefinitionReader.html[Javadoc].
840
880
841
881
842
882
843
883
844
884
=== Core Container Improvements
845
- There have been several general improvements to the core IoC container:
885
+ There have been several general improvements to the core container:
846
886
847
887
* Spring now treats <<beans-generics-as-qualifiers,__generic types__ as a form of
848
888
__qualifier__>> when injecting Beans. For example, if you are using a Spring Data
@@ -853,22 +893,23 @@ There have been several general improvements to the core IoC container:
853
893
* Beans can now be `Ordered` when they are <<beans-autowired-annotation,autowired into
854
894
lists and arrays>>. Both the `@Ordered` annotation and `Ordered` interface are
855
895
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
896
* The `@Lazy` annotation can now be used on injection points, as well as `@Bean`
863
897
definitions.
864
898
* The <<beans-java-bean-description,`@Description` annotation has been added>> for
865
899
developers using Java-based configuration.
866
- * It is now possible to specify a time zone with the `@Scheduled` annotation.
900
+ * A generalized model for <<beans-java-conditional,conditionally filtering beans>> has
901
+ been added via the `@Conditional` annotation. This is similar to `@Profile` but allows
902
+ for user-defined strategies to be developed.
903
+ * <<aop-pfb-proxy-types,CGLIB-based proxy classes>> no longer require a default
904
+ constructor. Support is provided via the http://code.google.com/p/objenesis/[objenesis]
905
+ library which is repackaged __inline__ and distributed as part of the Spring Framework.
906
+ With this strategy, no constructor at all is being invoked for proxy instances anymore.
907
+ * There is managed time zone support across the framework now, e.g. on `LocaleContext`.
867
908
868
909
869
910
870
911
871
- === Web Improvements
912
+ === General Web Improvements
872
913
Deployment to Servlet 2.5 servers remains an option, but Spring Framework 4.0 is now
873
914
focused primarily on Servlet 3.0+ environments. If you are using the
874
915
<<spring-mvc-test-framework,Spring MVC Test Framework>> you
@@ -886,37 +927,28 @@ have been made to Spring's Web modules:
886
927
Spring MVC applications.
887
928
888
929
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
930
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
931
918
- For more information consult the `GroovyBeanDefinitionReader`
919
- {javadoc-baseurl}/org/springframework/beans/factory/groovy/GroovyBeanDefinitionReader.html[Javadoc].
932
+ === WebSocket, SockJS, and STOMP Messaging
933
+ A new `spring-websocket` module provides comprehensive support for WebSocket-based,
934
+ two-way communication between client and server in web applications. It is compatible with
935
+ http://jcp.org/en/jsr/detail?id=356[JSR-356], the Java WebSocket API, and in addition
936
+ provides SockJS-based fallback options (i.e. WebSocket emulation) for use in browsers
937
+ that don't yet support the WebSocket protocol (e.g. IE < 10).
938
+
939
+ A new `spring-messaging` module adds support for STOMP as the WebSocket sub-protocol
940
+ to use in applications along with an annotation programming model for routing and
941
+ processing STOMP messages from WebSocket clients. As a result an `@Controller`
942
+ can now contain both `@RequestMapping` and `@MessageMapping` methods for handling
943
+ HTTP requests and messages from WebSocket-connected clients. The new `spring-messaging`
944
+ module also contains key abstractions from the
945
+ http://projects.spring.io/spring-integration/[Spring Integration] project such as
946
+ `Message`, `MessageChannel`, `MessageHandler` and others to serve as
947
+ a foundation for messaging applications.
948
+
949
+ For more details including a more thorough introduction, see the <<websocket>> section.
950
+
951
+
920
952
921
953
922
954
=== Testing Improvements
@@ -942,6 +974,8 @@ Framework 4.0 introduces several new features for use in unit and integration te
942
974
943
975
944
976
977
+
978
+
945
979
[[spring-core]]
946
980
= Core Technologies
947
981
[partintro]
@@ -36629,7 +36663,7 @@ WebSocket clients or to a specific user.
36629
36663
[[websocket-server]]
36630
36664
=== WebSocket Server
36631
36665
The Spring Framework provides a WebSocket API designed to adapt to various WebSocket engines.
36632
- For example it runs on JSR-356 runtimes such as Tomcat (7.0.47+) and Glassfish (4.0+) but
36666
+ For example it runs on JSR-356 runtimes such as Tomcat (7.0.47+) and GlassFish (4.0+) but
36633
36667
can also adapt to other WebSocket runtimes such as the Jetty (9.0+) native WebSocket support.
36634
36668
36635
36669
[NOTE]
@@ -36818,7 +36852,7 @@ requests -- such as Spring MVC's `DispatcherServlet`.
36818
36852
This is a significant limitation of JSR-356 that Spring's WebSocket support
36819
36853
addresses by providing a server-specific `RequestUpgradeStrategy` even when
36820
36854
running in a JSR-356 runtime. At present such support is available on
36821
- Tomcat 7.0.47+, Jetty 9.0+, and Glassfish 4.0+. Additional support will be
36855
+ Tomcat 7.0.47+, Jetty 9.0+, and GlassFish 4.0+. Additional support will be
36822
36856
added as more WebSocket runtimes become available.
36823
36857
36824
36858
[NOTE]
@@ -45058,12 +45092,14 @@ below).
45058
45092
[NOTE]
45059
45093
====
45060
45094
The default key generation strategy changed with the release of Spring 4.0. Earlier
45061
- versions of Spring used a key generation strategy that only considered the `hashCode()`
45062
- of parameters and not `equals()`, this often caused unexpected key collisions (see
45063
- https://jira.springsource.org/browse/SPR-10237[SPR-10237] for background).
45064
-
45065
- If you want to use the previous key generator, you can use the
45066
- `org.springframework.cache.interceptor.DefaultKeyGenerator` class.
45095
+ versions of Spring used a key generation strategy that, for multiple key parameters,
45096
+ only considered the `hashCode()` of parameters and not `equals()`; this could cause
45097
+ unexpected key collisions (see https://jira.springsource.org/browse/SPR-10237[SPR-10237]
45098
+ for background). The new 'SimpleKeyGenerator' uses a compound key for such scenarios.
45099
+
45100
+ If you want to keep using the previous key strategy, you can configure the deprecated
45101
+ `org.springframework.cache.interceptor.DefaultKeyGenerator` class or create a custom
45102
+ hash-based 'KeyGenerator' implementation.
45067
45103
====
45068
45104
45069
45105
0 commit comments