
Spring Framework 5.2 now requires Jackson 2.9.7+ and explicitly supports the recently released Jackson 2.10 GA. See gh-23522.
In Reactor Core 3.3, the Kotlin extensions are deprecated and replaced by a dedicated reactor-kotlin-extensions project/repo. You may have to add io.projectreactor.kotlin:reactor-kotlin-extensions dependency to your project and update related packages to use the non-deprecated variants.
Spring's annotation retrieval algorithms have been completely revised for efficiency and consistency, as well as for potential optimizations through annotation presence hints (e.g. from a compile-time index). This may have side effects -- for example, finding annotations in places where they haven't been found before or not finding annotations anymore where they have previously been found accidentally. While we don't expect common Spring applications to be affected, annotation declaration accidents in application code may get uncovered when you upgrade to 5.2. For example, all annotations must now be annotated with @Retention(RetentionPolicy.RUNTIME) in order for Spring to find them. See gh-23901, gh-22886, and gh-22766.
@RequestMapping without path attribute
@RequestMapping() and meta-annotated variants @GetMapping(), PostMapping(), etc., without explicitly declared path patterns are now equivalent to RequestMapping("") and match only to URLs with no path. In the absence of declared patterns previously the path was not checked thereby matching to any path. If you would like to match to all paths, please use "/**" as the pattern. gh-22543
@EnableWebMvc and @EnableWebFlux Infrastructure
@Bean methods in Web**ConfigurationSupport now declare bean dependencies as method arguments rather than use method calls to make it possible to avoid creating proxies for bean methods via @Configuration(proxyBeanMethods=false) which Spring Boot 2.2 now does. This should not affect existing applications but if sub-classing Web**ConfigurationSupport (or DelegatingWeb**Configuration) and using proxyBeanMethods=false be sure to also to declare dependent beans as method arguments rather than using method calls. See gh-22596
Deprecation of MediaType.APPLICATION_JSON_UTF8 and MediaType.APPLICATION_PROBLEM_JSON_UTF8
Since the related Chrome bug is now fixed since September 2017, Spring Framework 5.2 deprecates MediaType.APPLICATION_JSON_UTF8 and MediaType.APPLICATION_PROBLEM_JSON_UTF8 in favor of MediaType.APPLICATION_JSON and MediaType.APPLICATION_PROBLEM_JSON and uses them by default. As a consequence, integration tests relying on the default JSON content type may have to be updated. See gh-22788 for more details.
CORS handling
CORS handling has been significantly updated in Spring Framework 5.2:
- CORS processing is now only used for CORS-enabled endpoints
- CORS processing for skipped for same-origin requests with an
Originheader - Vary headers are added for non-CORS requests on CORS endpoints
These changes introduce an AbstractHandlerMapping#hasCorsConfigurationSource method (in both Spring MVC and WebFlux) in order to be able to check CORS endpoints efficiently. When upgrading to Spring Framework 5.2, handler mapping extending AbstractHandlerMapping and supporting CORS should override hasCorsConfigurationSource with their custom logic.
Use of Path Extensions Deprecated in Spring MVC
Config options for suffix pattern matching in RequestMappingHandlerMapping have been deprecated, and likewise config options to resolve acceptable media types from the extension of a request path in ContentNegotiationManagerFactoryBean have also been deprecated. This is aligned with defaults in Spring Boot auto configuration and Spring WebFlux does not offer such options. See gh-24179 and related issues for details and further plans towards 5.3.
Encoder Contract
Custom implementations of Encoder must implement the new encodeValue which is invoked from ServerSentEventHttpMessageWriter or otherwise that would fail at runtime.
The mock JNDI support in the spring-test module has been deprecated. If you have been using classes such as the SimpleNamingContext and SimpleNamingContextBuilder, you are encouraged to migrate to a complete JNDI solution from a third party such as Simple-JNDI. [gh-22779]
升级到 5.2 版 图书馆
Spring Framework 5.2 现在需要 Jackson 2.9.7+ 并明确支持最近发布的 Jackson 2.10 GA。见gh-23522。
在 Reactor Core 3.3 中,不推荐使用 Kotlin 扩展,取而代之的是专用的reactor-kotlin-extensions项目/存储库。您可能必须向io.projectreactor.kotlin:reactor-kotlin-extensions项目添加依赖项并更新相关包以使用未弃用的变体。
Spring 的注释检索算法已针对效率和一致性以及通过注释存在提示(例如,来自编译时索引)进行的潜在优化进行了全面修改。这可能会产生副作用——例如,在以前没有找到注释的地方找到注释,或者在以前偶然发现注释的地方不再找到注释。虽然我们预计常见的 Spring 应用程序不会受到影响,但当您升级到 5.2 时,可能会发现应用程序代码中的注释声明事故。例如,所有注解现在必须被注解,@Retention(RetentionPolicy.RUNTIME)以便 Spring 找到它们。请参阅gh-23901、gh-22886和gh-22766。
@RequestMapping没有路径属性
@RequestMapping()和元注释变体@GetMapping(),PostMapping()等,没有明确声明path的模式现在等效于RequestMapping("")并仅匹配没有路径的 URL。在没有先前声明的模式的情况下,不会检查路径,从而匹配任何路径。如果您想匹配所有路径,请使用"/**"作为模式。GH-22543
@EnableWebMvc和@EnableWebFlux基础设施
@Bean现在的方法Web**ConfigurationSupport将 bean 依赖项声明为方法参数,而不是使用方法调用来避免为@Configuration(proxyBeanMethods=false)Spring Boot 2.2 现在所做的 bean 方法创建代理。这不应该影响现有的应用程序,但如果子类化Web**ConfigurationSupport(或DelegatingWeb**Configuration)和使用proxyBeanMethods=false确保也将依赖 bean 声明为方法参数而不是使用方法调用。见gh-22596
弃用MediaType.APPLICATION_JSON_UTF8和MediaType.APPLICATION_PROBLEM_JSON_UTF8
由于自 2017 年 9 月以来相关的 Chrome 错误现已修复,Spring Framework 5.2 弃用MediaType.APPLICATION_JSON_UTF8并MediaType.APPLICATION_PROBLEM_JSON_UTF8支持MediaType.APPLICATION_JSON并MediaType.APPLICATION_PROBLEM_JSON默认使用它们。因此,可能必须更新依赖于默认 JSON 内容类型的集成测试。有关详细信息,请参阅gh-22788。
CORS 处理
在 Spring Framework 5.2 中对CORS 处理进行了重大更新:
- CORS 处理现在仅用于启用 CORS 的端点
Origin跳过带有标头的同源请求的 CORS 处理- 为 CORS 端点上的非 CORS 请求添加了不同的标头
这些更改引入了一种AbstractHandlerMapping#hasCorsConfigurationSource方法(在 Spring MVC 和 WebFlux 中),以便能够有效地检查 CORS 端点。升级到 Spring Framework 5.2 时,扩展AbstractHandlerMapping和支持 CORS 的处理程序映射应覆盖hasCorsConfigurationSource其自定义逻辑。
在 Spring MVC 中不推荐使用路径扩展
后缀模式匹配的配置选项RequestMappingHandlerMapping已被弃用,同样,从请求路径的扩展中解析可接受的媒体类型的配置选项ContentNegotiationManagerFactoryBean也已弃用。这与 Spring Boot 自动配置中的默认值一致,并且 Spring WebFlux 不提供此类选项。有关详细信息和对 5.3 的进一步计划,请参阅gh-24179和相关问题。
Encoder合同
的自定义实现Encoder必须实现新的encodeValue,该新encodeValue被调用,ServerSentEventHttpMessageWriter否则会在运行时失败。
模块中的模拟 JNDI 支持spring-test已被弃用。如果您一直在使用诸如SimpleNamingContextand之类的类SimpleNamingContextBuilder,我们鼓励您从第三方(例如Simple-JNDI )迁移到完整的 JNDI 解决方案。[gh-22779]
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)