/
Spring Boot 1.x to 2.x Migration Notes

Spring Boot 1.x to 2.x Migration Notes

Have been upgrading services from Spring Boot 1.4.x or 1.5.x to 2.2.2. These notes do not apply as well to other 2.x versions (like 2.1).

  • Need to define Spring Boot Gradle Plugin version to Spring Boot version desired (e.g. 2.2.2).

    • Whatever Spring Boot version is used, since we use OAuth2 for security, we need to explicitly define in gradle the same version for Spring OAuth2 Security

      • org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure:2.2.2.RELEASE

  • Update Flyway to v6 (6.0.8, according to https://docs.spring.io/spring-boot/docs/2.2.x/reference/html/appendix-dependency-versions.html)

    • Because of this, will need to refactor Flyway-related Java callback code to use new classes and methods

  • Update RAML tester and RAML parser to latest (0.8.15 and 0.8.37), because of test failures

  • Update Mockito and PowerMock to latest (may have been some test failures without updating)

  • Update REST Assured to at least version 3.3, because of some integration test issues

  • JPA repository methods have been renamed (e.g. findOne to findById, delete to deleteById, etc.), and now return Optional

  • PageRequest constructor has been replaced with PageRequest.of(), same with Sort

  • MAJOR Spring Framework v5 has dropped JasperReports support, in favor of clients using native JasperReports API (Drop JasperReports support [SPR-13294] · Issue #17884 · spring-projects/spring-framework), so any services that use it will need to be refactored (see openlmis-report for a refactor pattern)

  • For some reason, integration tests now require some API definitions in the YAML have an entry for “Keep-Alive” header

  • Flyway config in application properties file uses spring.flyway rather than flyway now

  • Bean definition overriding is now disabled by default, may need to set spring.main.allow-bean-definition-overriding=true for test configurations

  • AUTH SERVICE ONLY - Spring Boot 2 does not use a plaintext password encoder anymore, but one that adds a encode prefix to each password; current workaround is to use the NoOpPasswordEncoder, but will probably need to use a real password encoder and migrate all passwords in the system

  • Pagination does not allow a null sort, and by default returns an object rather than an array, so add CustomSortSerializer to serialize Sort

  • Make sure spring.flyway.table=schema_version, newer versions of Flyway has a new default table name

  • Since JSON response has its Sort property modified, add JsonSortSerializer so integration tests will pass. It is also recommended to change PageImplRepresentation class which extends PageImpl to PageDto implementing Page interface

 

Related content

667: Add Spring Security to Service Example
667: Add Spring Security to Service Example
More like this
OpenLMIS 3.0 Database Migrations
OpenLMIS 3.0 Database Migrations
More like this
Service Migration Tests
Service Migration Tests
More like this
Technical Debt for v3
Technical Debt for v3
More like this
Backlog Grooming Sprint 22
Backlog Grooming Sprint 22
More like this
2.0.1 Release - 18 March 2016
2.0.1 Release - 18 March 2016
More like this

OpenLMIS: the global initiative for powerful LMIS software