springboot 升級 2.0 踩坑 指南

springboot 升級 2.0 踩坑 指南

 

1.spring-cloud 需要配合升級

目前 我們採用的是
boot的 2.1.7.RELEASE 版本 對應 cloud的 Greenwich.SR2版本

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.7.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

<spring-cloud.version>Greenwich.SR2</spring-cloud.version>

2. druid 組件 使用 log4j 需要 做一下 轉換

採用 引入log4j-over-slf4j包.所有日誌最終都統一到slf4j,並由logback 去輸出日誌.

<dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>log4j-over-slf4j</artifactId>
            <version>1.6.1</version>
        </dependency>

3. 如果使用 velocity 推薦 使用 freemarker

4.如果不是用 eureka註冊中心 要關閉掉.

eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false

5. springMvc 的一些 配置要做一下修改 主要是 一些 駱駝寫法 改成 - 去連接.

spring.http.multipart.maxFileSize=500Mb
spring.http.multipart.maxRequestSize=1000Mb

改成

spring.servlet.multipart.max-file-size=100MB
spring.servlet.multipart.max-request-size=1000MB

6. mysql 使用 mysql-connector-java 依然使用 5.x版本

7.WebMvcConfigurerAdapter升級

WebMvcConfigurerAdapter改爲WebMvcConfigurationSupport。

:千萬別implements WebMvcConfigurer有坑。

8. Failed to bind properties under '' to com.zaxxer.hikari.HikariDataSource

application.properties中添加

spring.datasource.driver-class-name=com.mysql.jdbc.Driver
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章