New features and enhancements in Spring 4.3

Core container improvements

  • The core container additionally provides richer metadata to improve programming.
  • By default Java 8 methods are detected as getter/setter methods for bean properties.
  • If the target bean defines only one constructor, it does not need to specify the @Autowiredannotation
  • @ConfigurationClasses support constructor injection.
  • Any SpEL expression used to specify @EventListenera conditionreference to a bean (for example @beanName.method()).
  • Composition annotations can now be overridden with an element of type array component that contains the array property in the meta-annotation. For example, @RequestMappingthe String[] pathcan be String pathoverridden .
  • @Scheduledand @Schedulesare now used as meta-annotations to create custom composition annotations through property overrides.
  • @ScheduledAny scoped beans are properly supported.

Data access improvements

jdbc:initialize-databaseand jdbc:embedded-databasesupports configurable separators to be 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 calculated only once. This is an optional feature, enabled by setting @Cacheablea new syncproperty . This feature introduces Cachea breaking change to the interface, that get(Object key, Callable<T> valueLoader)methods have been added.

Spring 4.3 also improves the cache abstraction as follows:

  • SpEL expressions for cache related annotations can now refer to beans (ie @beanName.method()).
  • ConcurrentMapCacheManagerand now supports serialization of cached entities ConcurrentMapCachevia a new property. , , and are now used as meta-annotations to create custom composition annotations via property overrides.storeByValue@Cacheable@CacheEvict@CachePut@Caching

JMS improvements

  • @SendToA common reply target can now be specified at the class level.
  • @JmsListenerand @JmsListenersare now used as meta-annotations to create custom composition annotations through property overrides.

Web improvements

  • Built-in support for HTTP HEAD and HTTP OPTIONS.
  • The new combined annotations @GetMapping, @PostMapping, @PutMapping, @DeleteMapping, and @PatchMappingare used @RequestMapping.
  • New @RequestScope, @SessionScope, and composite annotations @ApplicationScopefor web scope
  • The new @RestControllerAdviceannotation is a@ControllerAdvice semantic combination of and@ResponseBody
  • @ResponseStatusNow supported at the class level and inherited by all methods
  • New @SessionAttributeannotation for accessing session properties (see example )
  • New @RequestAttributeannotation for accessing request attributes (see example )
  • @ModelAttributeAllows binding=falseto (see reference)
  • Errors and custom throws will be unified into MVC exception handlers
  • Consistent handling of HTTP message conversion encodings, including default UTF-8 for multipart text content
  • Static resource processing uses configured ContentNegotiationManagermedia type calculations
  • RestTemplateand AsyncRestTemplatesupports DefaultUriTemplateHandlerstrict URI variable encoding via
  • AsyncRestTemplateSupport request interception

WebSocket message improvements

@SendToand @SendToUsercan now be specified at the class level to share a common destination.

Test improvements

  • To support Spring TestContext Framework, JUnit 4.12 or higher is now required
  • new SpringRunnerassociated withSpringJUnit4ClassRunner
  • Test-related annotations can now be declared on interfaces. For example, using a test interface on a Java 8 based interface
  • Empty declarations will @ContextConfigurationnow be completely ignored if a default XML file, Groovy script, or @Configurationtype is detected
  • @TransactionalTest methods are no longer required public(eg, in TestNG and JUnit 5)
  • @BeforeTransactionand are @AfterTransactionno longer required publicand are declared on default methods of Java 8 based interfaces
  • The cache in the Spring TestContext Framework is ApplicationContextnow bounded to a default maximum size of 32 and a least recently used eviction policy. The maximum size can be set by setting spring.test.context.cache.maxSizea JVM system property or Spring configuration.
  • ContextCustomizerThe API is used for custom testing ApplicationContextafter the bean definition is loaded into the context but before the context is refreshed. Custom tools can be registered globally by third parties without the need to implement a custom one ContextLoader.
  • @Sqland @SqlGroupare now used as meta-annotations to create custom composite annotations by overriding properties
  • ReflectionTestUtilsProxies are now automatically unwrapped when you set or get a field.
  • Server-side Spring MVC testing supports response headers with multiple values.
  • Server-side Spring MVC tests parse the request content of the form data and populate request parameters.
  • Server-side Spring MVC tests support mock-style assertions to invoke handler methods.
  • Client-side REST testing support allows specifying how many requests are expected and whether the expected declaration order should be ignored (see 15.6.3, “Client-Side REST Testing” ).
  • Client-side REST testing supports the expectation of request body form data.

Support for new class libraries and servers

  • Hibernate ORM 5.2 (also good support for 4.2/4.3 and 5.0/5.1, 3.6 not recommended)
  • Jackson 2.8 (with Spring 4.3, minimum 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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324536472&siteId=291194637