Note on migrating Spring Boot 1.5 to 2.0

Note on migrating Spring Boot 1.5 to 2.0

1. Useful links
First of all, you should read recommended links:

2. Tips and solution for problems

  • Table ‘hibernate_sequence’ doesn’t exist

Solution: Add config spring.jpa.properties.hibernate.id.new_generator_mappings=false

  • Spring Boot 2.0 use HikariCP by default, so you should add config for HikariCP

Solution:

Add config

spring.datasource.hikari.max-lifetime={max-lifetime-value}
spring.datasource.hikari.idle-timeout={idle-timeout-value}

Note:
– Value for config must be in millisecond.
– spring.datasource.hikari.idle-timeout < spring.datasource.hikari.max-lifetime < database wait_timeout
– For MySQL/MariaDB, use query SHOW GLOBAL VARIABLES LIKE 'wait_timeout'; to get wait_timeout, this value is in second
– For example, database wait_timeout = 600 second, so I can assign value as below:
spring.datasource.hikari.max-lifetime=500000
spring.datasource.hikari.idle-timeout=400000

  • Use MariaDB driver for MariaDB instead of MySQL Driver

Solution:
Step 1: Remove MySQL Driver:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
Step 2: Add MariaDB Driver:
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<scope>runtime</scope>
</dependency>
Step 3: Change database connection URL: change from jdbc:mysql://... to jdbc:mariadb://...

%d bloggers like this: