Reproduced from https://my.oschina.net/waylau/blog/698186 core container improvements
- The core container provides additional metadata to improve programming.
- The default Java 8 method detects the Getter/setter method as a bean property.
- If the target bean defines only one constructor, it does not need to specify
@Autowired annotations
@ConfigurationClass supports constructor injection.
- Any spel expression is used for
@EventListener the specified condition reference to the bean (for example @beanName.method() ).
- The constituent annotations can now be overridden with an element of the array component type that contains the array attributes in the meta annotations. For example, the
@RequestMapping String[] path can be overridden in constituent annotations String path .
@ScheduledAnd @Schedules now are used as meta annotations to create custom constituent annotations through property overrides.
@ScheduledAppropriate support for any bean in the range.
Data access Improvements
jdbc:initialize-databaseand jdbc:embedded-database support for configurable separators is applied to each script.
Cache improvements
Spring 4.3 allows implementations to synchronize when a given key is called concurrently, so that the corresponding value is computed only once. This is an optional feature that is enabled by setting @Cacheable the new sync properties. This feature introduces Cache a significant change to the interface, that is, the get(Object key, Callable<T> valueLoader) method has been added.
Spring 4.3 also improved the cache abstraction as follows:
- Spel expressions for Cache-related annotations, you can now refer to the bean (that is
@beanName.method()) ).
ConcurrentMapCacheManagerand ConcurrentMapCache now storeByValue supports the serialization of cached entities through a new property. @Cacheable, @CacheEvict @CachePut and @Caching is now used as meta annotations to create custom constituent annotations through property overrides.
JMS improvements
@SendToYou can now specify a common reply target at the class level.
@JmsListenerAnd @JmsListeners now are used as meta annotations to create custom constituent annotations through property overrides.
Web improvements
- Built-in support for HTTP HEAD and HTTP OPTIONS.
- New combinations of annotations
@GetMapping ,,, @PostMapping @PutMapping @DeleteMapping , and @PatchMapping used @RequestMapping .
- See
@RequestMapping combination variants
- New
@RequestScope , @SessionScope , and @ApplicationScope combined annotations for web-scoped
- Request scope, Session scope, and application scope
- New
@RestControllerAdvice annotations are a @ControllerAdvice @ResponseBody combination of semantics and
@ResponseStatusis now supported at the class level and inherited by all methods
- New
@SessionAttribute annotations are used to access session properties (see example)
- New
@RequestAttribute annotations are used to access request properties (see example)
@ModelAttributeAllow pass binding=false to avoid data binding (see reference)
- Errors and custom throws will be uniformly processed in the MVC exception handler
- HTTP message conversion encoding consistent processing, including default UTF-8 for multipart text content
- Static resource handling uses configuration
ContentNegotiationManager for media type calculation
RestTemplateand AsyncRestTemplate supported by DefaultUriTemplateHandler the implementation of strict URI variable encoding
AsyncRestTemplateSupport for request interception
WebSocket Message Improvements
@SendToAnd @SendToUser now can be specified at the class level to share common destinations.
Test improvements
- To support the Spring TestContext Framework, JUnit 4.12 or later is now required
- The new
SpringRunner link toSpringJUnit4ClassRunner
- The test-related annotations can now be declared on the interface. For example, using a test interface on a Java 8-based interface
- The null declaration
@ContextConfiguration will now be completely ignored if the default XML file is detected, Groovy script, or @Configuration type
@TransactionalTest methods are no longer required public (e.g., in TestNG and JUnit 5)
@BeforeTransactionAnd @AfterTransaction is no longer needed public , and is declared on the default method of the Java 8-based interface
- The cache in the spring TestContext Framework
ApplicationContext now has bounds for the 32 default maximum size and the least recently used eviction policy. The maximum size can be set by setting called spring.test.context.cache.maxSize a JVM system property or Spring configuration.
ContextCustomizerThe API is used for custom tests ApplicationContext after the bean definition is loaded into the context but before the context is refreshed. Custom tools can be registered globally by third parties without having to implement a custom ContextLoader .
@SqlAnd @SqlGroup now as meta annotations Create custom combo annotations by overriding properties
ReflectionTestUtilsThe proxy is now automatically unlocked when a field is set or get.
- The server-side Spring MVC Test supports response headers with multiple values.
- The server-side Spring MVC test parses the request contents of the form data and populates the request parameters.
- The server-side Spring MVC test supports mock assertions to invoke handler methods.
- Client rest test support allows you to specify how many times the expected request should be ignored (see 15.6.3, "Client Rest test").
- Client REST testing supports the expectation of requesting the principal form data.
Support for new class libraries and servers
- Hibernate ORM 5.2 (also very good support for 4.2/4.3 and 5.0/5.1, not recommended 3.6)
- Jackson 2.8 (at Spring 4.3, lowest to Jackson 2.6+)
- OkHttp 3.x (still supports OkHttp 2.x in parallel)
- Netty 4.1
- Undertow 1.4
- Tomcat 8.5.2 and 9.0 M6
Reference reference
- Spring Framework 4.x Reference document in Chinese
New features and enhancements for Spring 4.3