Updated on 2022-11-14 GMT+08:00

Incompatibilities During Spring Boot Upgrade from 2.0.x.RELEASE to 2.3.x.RELEASE

FeignClient Name Issue

  • Description

    In earlier Spring Boot versions, Bean name can be overwritten. In new versions, this function is disabled by default and can be enabled by using the configuration item.

  • Solutions

    Configure the following to enable overwriting:

    spring:
      main:    
        allow-bean-definition-overriding: true

Spring Data API Change

  • Description

    The Spring Data API fluctuates.

  • Solutions

    Use the new API to modify the code. For example, change new PageImpl to PageRequest.of and new Sort to Sort.of.

JPA Change: Multiple Entities Correspond to One Table

  • Description

    In later versions, one entity corresponds to one table.

  • Solutions

    Currently, there is no solution. Alternatively, adjust the code structure to the constraints of the new version.

Mongo Client Upgrade Change

  • Description

    The MongoDbFactory API has changed and needs to be adjusted to the new version.

  • Solutions
    @Bean
    public MappingMongoConverter mappingMongoConverter(MongoDbFactory factory, MongoMappingContext context, BeanFactory beanFactory) {
       DbRefResolver dbRefResolver = new DefaultDbRefResolver(factory);
       MappingMongoConverter mappingConverter = new MappingMongoConverter(dbRefResolver, context);
       mappingConverter.setCustomConversions(beanFactory.getBean(MongoCustomConversions.class));
       // other customization
       return mappingConverter;
    }
    
    @Bean
    public MongoClientOptions mongoOptions() {
           return MongoClientOptions.builder().maxConnectionIdleTime(60000).socketTimeout(60000).build();   
    }