Spring Boot upgrade to 2.1.6 release

Process

To upgrade Spring Boot, you have to upgrade the tools and libs as well, including Gradle, Tomcat, Kafka, Redis, Zoomkeeper, Hanadb .etc

  • Find the dependency versions suit for your Spring Boot at here.
  • Do as the guideline said. 
  • Not only the Spring Boot migration guideline, but also the tools you will upgrade.

Problems happened and solutions

  • bootJar and jar: jar is default disabled and bootJar is default abled, if you are using project dependency(e.g. compile/implementation project(":projectname")), you need to care about this.
  • ConfigurationProperties: the prefix name must be lowercase, that means the first level of the profile's properties must be lowercase.
  • WARN Message for Implicit 'open-in-view': a new feature that can avoid lazy loading exception from controller(web views), can disabled it by set

    spring.jpa.open-in-view: false

     

  • New id generator(sequence generator): SequenceStyleGenerator is default abled, you can disabled it by set 

    spring.jpa.hibernate.use-new-id-generator-mappings: false

    Or you can use replace the deprecated @SequenceGenerator, refer here .  

    This is a simple example: 

    @Id
    @GeneratedValue(strategy= GenerationType.SEQUENCE, generator="ID_SEQ")
    @GenericGenerator(name = "ID_SEQ",
    strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator",
    parameters = {
    @Parameter(name = SEQUENCE_PARAM, value = "API_CLIENT_VERSION_SEQ"),
    //"legacy-hilo" optimizer using the same algorithm as @SequenceGenerator, and the allocationSize = INCREMENT_PARAM +1
    @Parameter(name = INCREMENT_PARAM, value = "49"),
    @Parameter(name = OPT_PARAM, value = "legacy-hilo")
    })
    @Column
    private Long id;
  • Json date format: The date format which json returned has been changed form timestamps(createTime: 1544693261000) to UTC string("2018-12-13T09:27:41.000+0000") at Spring Boot2, you can use old format by set

    spring.jackson.serialization.write-dates-as-timestamps: true
  • Tomcat URI check: if you're using tomcat8 then no "_" is available for an URI.
  • Additional profiles for Spring Boot2: use spring.config.additional-location instead of spring.config.location.
  • Get rid of lightadmin:lightadmin is an inspect tool but intergrated with Spring Boot1.
  • Hana upgrade: have to add columnDefinition for tinyint clumns and set 0/1 to replace false/true.

Guidelines and useful links 

  • Springboot Migration Guides

v1.4 → v1.5

v1.5 → v2.0

posted @ 2020-01-31 14:16  minjun.jiang  阅读(242)  评论(0)    收藏  举报