189 8069 5689

SpringBoot2.1升级2.2.x迁移方法

这篇文章主要讲解了“SpringBoot2.1升级2.2.x迁移方法”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“SpringBoot2.1升级2.2.x迁移方法”吧!

专注于为中小企业提供成都网站设计、成都做网站服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业大宁免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了1000多家企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。

1. MediaType.APPLICATION_JSON_UTF8_VALUE ===>>> MediaType.APPLICATION_JSON_VALUE

  • MediaType.APPLICATION_JSON_UTF8_VALUE 已被标记@Deprecated

  • 等效于{@link MediaType#APPLICATION_JSON_UTF8}的字符串。@deprecated自Spring Framework 5.2起不推荐使用,而推荐使用{@link #APPLICATION_JSON_VALUE}由于主要的浏览器(例如Chrome)现在已符合规范并正确解释了UTF-8特殊字符 不需要{@code charset = UTF-8}参数。

2. org.springframework.data.domain.Sort 过时 新的替代方法: ????

  • 之前的写法:Sort sort = new Sort(Sort.Direction.DESC, "taskId"); 如何替代?

  • 现在的写法:Sort sort = Sort.by(Sort.Direction.DESC, "taskId"); 原因:private Sort(Direction direction, List properties)是内部构造方法,不能在外部使用,外部使用Sort.by(Direction direction, List properties);

3.Actuator HTTP Trace and Auditing are disabled by default 默认关闭 如何配置开启

The Actuator HTTP Trace and Auditing features are not enabled by default anymore, since the default repositories implementations are in-memory and may consume too many resources and are not cluster friendly For robust, production-grade HTTP tracing we recommend the use of Spring Cloud Sleuth or similar.

To enable HTTP tracing, contribute a bean implementing HttpTraceRepository or AuditEventRepository to turn those features back on. Configuration properties are available to turn those features off even in the presence of those beans (see management.auditevents.enabled and management.trace.http.enabled)

4.Lazy initialization

  • It is now possible to enable global lazy initialization to reduce startup time via the spring.main.lazy-initialization property. Please note that using that feature comes at a cost:

Handling of HTTP requests may take longer while any deferred initialisation occurs

Failures that would normally occur at startup will now not occur until later

Individual beans can opt out of lazy initialization by annotating their definition with @Lazy(false). Where it is not possible to use @Lazy(false) to opt out of lazy initialization, a LazyInitializationExcludeFilter bean can be used instead. For example, to never set IntegrationFlow beans to lazy, you can use the following code:

@Bean static LazyInitializationExcludeFilter integrationLazyInitExcludeFilter() { return LazyInitializationExcludeFilter.forBeanTypes(IntegrationFlow.class); }

5.Reactor响应式编程事务支持的增强

Reactive Elasticsearch Auto-configuration

6.Spring Boot如何让Web API自动生成文档,并解决swagger-annotations的API注解description属性废弃的问题

  • https://blog.csdn.net/zhangchao19890805/article/details/54863338

  • 旧: @Api(description="归档")

  • 新: @Api(tags={"归档"})

JMX now disabled by default

  • As of #16090, JMX is not enabled by default anymore. This feature can be enabled with the configuration property spring.jmx.enabled=true. If you’re using IDE features to administer your applications, you may want to enable that flag there as well.

7.BlogServerApplication: Failed to retrieve application JMX service URL

8.@ConfigurationProperties scanning

Dependency Upgrades Spring Boot 2.2 moves to new versions of several Spring projects:

Reactor Dysprosium

Spring AMQP 2.2

Spring Batch 4.2

Spring Data Moore

Spring Framework 5.2

Spring HATEOAS 1.0

Spring Integration 5.2

Spring Kafka 2.3

Spring Security 5.2

Spring Session Corn

Numerous third-party dependencies have also been updated, some of the more noteworthy of which are the following:

Artemis 2.9

Elasticsearch 6.7

Flyway 6.0

Git Commit ID Plugin 3.0

Hazelcast 3.12

HSQLDB 2.5

Jackson 2.10

Jedis 3.1

Jersey 2.29

Kafka 2.3

Lettuce 5.2

Micrometer 1.3

Mockito 3.1

Solr 8.0

Miscellaneous Apart from the changes listed above, there have also been lots of minor tweaks and improvements including:

loadOnStartup can be configured if you’re wrapping a Servlet as an actuator endpoint.

Flyway bootstrap failures are covered by a dedicated FailureAnalyzer

The MessageConverter for Kafka batch listeners is properly auto-configured.

Add support for Jaybird 4 (jdbc:firebird prefix).

Add opt-in support for Neo4j-OGM native types.

Client-side HTTP-metrics have an outcome tag.

Numerous upgrades of third-party dependencies

Prometheus push gateway can now be configured using https

Printer and Parser beans are automatically registered with the application conversion service.

When using the H2 console auto-configuration, JDBC connection URL is now logged at startup for ease of connection.

Couchbase role-based access is now supported via spring.couchbase.username and spring.couchbase.password.

Support for OAuth3 resource server opaque token authentication has been added and can be configured using the spring.security.oauth3.resourceserver.opaquetoken configuration properties.

The application will fail fast if spring.config.location specifies a file with an extension that no PropertySourceLoader can read.

The layout to use to repackage the application can be set on the command line with Maven using the spring-boot.repackage.layout property.

RestTemplateBuilder#defaultHeader accepts more than one value.

Custom resource handlers can serve a favicon.

Kafka’s RecordInterceptor is detected and associated to the auto-configured listener container.

YAML configuration can now use on or off for boolean types.

Actuator discovery page is now available on / when using a separate management port.

@WebMvcTest now scans HandlerInterceptor beans.

@WebFluxTest scans WebFilter beans.

Configurable timeout for JMS listener container’s receive.

Support for Spring Session’s flush mode.

Support for Spring AMQP’s confirm-type.

Application properties for configuring Jetty’s thread pool.

Support for parallel test execution when using @AutoConfigureMockMvc with JUnit 5.

Zip64 files are now supported inside "Fat Jars".

The ROLLING_FILE_LOG_PATTERN is now exposed for use in logback configurations.

You can now inject and use a customized WebTestClient in any @SpringBootTest.

Dependency management for Oracle’s JDBC driver has been added.

Dependency management for Awaitility has been added.

Deprecations in Spring Boot 2.2 The logging.file property has been renamed to logging.file.name.

The logging.path property has been renamed to logging.file.path.

The server.connection-timeout property has been deprecated in favor of server-specific properties since their behaviors are not strictly the same.

The server.use-forward-headers property has been deprecated in favor of server.forward-headers-strategy; previously server.use-forward-headers=true would use the web server native support. You can now achieve the same with server.forward-headers-strategy=native. Because each server has a specific behavior, we now offer an alternative which relies on Spring’s ForwardedHeaderFilter: server.forward-headers-strategy=framework. Developers should use the option that fits best their use case.

ReactiveWebServerApplicationContext#getWebServerFactory.

The agent property of the Maven plugin has been renamed to agents.

Joda time support is deprecated in favour of java.time.

ApplicationHealthIndicator in favour of PingHealthIndicator that is always contributed.

ConfigurationBeanFactoryMetadata in favour of ConfigurationPropertiesBean.

ConfigurationPropertiesBindingPostProcessor constructors in favor of @EnableConfigurationProperties or the register method.

ConfigurationPropertiesBindingPostProcessor.VALIDATOR_BEAN_NAME has moved to EnableConfigurationProperties.VALIDATOR_BEAN_NAME.

ConfigurationPropertiesBindingPostProcessorRegistrar in favor of @EnableConfigurationProperties.

WebTestClientBuilderCustomizer has been relocated to org.springframework.boot.test.web.reactive.server.

参考

  • Spring-Boot-2.2-Release-Notes

感谢各位的阅读,以上就是“SpringBoot2.1升级2.2.x迁移方法”的内容了,经过本文的学习后,相信大家对SpringBoot2.1升级2.2.x迁移方法这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是创新互联,小编将为大家推送更多相关知识点的文章,欢迎关注!


文章题目:SpringBoot2.1升级2.2.x迁移方法
网站网址:http://cdxtjz.cn/article/psgdpc.html

其他资讯