Uploaded image for project: 'Spring Data REST'
  1. Spring Data REST
  2. DATAREST-538

Update RepositoryRestMvcConfiguration so that the bean factory knows that Jackson converter beans are type constrained

    XMLWordPrintable

    Details

      Description

      In Spring Boot, we'd like to be able to be able to auto-configure a general-purpose MappingJackson2HttpMessageConverter even when there are one or more TypeConstrainedMappingJackson2HttpMessageConverter beans in the context. To do so we plan to enhance @ConditionalOnMissingBean so that it can be configured to ignore beans of certain types, for example:

      @Bean
      @ConditionalOnMissingBean(value = MappingJackson2HttpMessageConverter.class, ignoredType = "org.springframework.hateoas.mvc.TypeConstrainedMappingJackson2HttpMessageConverter")
      public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() {
          // …
          return converter;
      }
      

      This only works if the beans that we want to ignore are exposed to the bean factory as being TypeConstrainedMappingJackson2HttpMessageConverter instances. This isn't the case with RepositoryRestMvcConfiguration as both halJacksonHttpMessageConverter and jacksonHttpMessageConverter are exposed as MappingJackson2HttpMessageConverter instances.

      I'd like RepositoryRestMvcConfiguration to provide more type information to the bean factory by exposed both Jackson converter beans as TypeConstrainedMappingJackson2HttpMessageConverter. Ideally, this change would be made in Evans and later, allowing us to offer a fix in Spring Boot 1.2.x and later.

      A pull request is on its way.

        Attachments

          Activity

            People

            Assignee:
            olivergierke Oliver Drotbohm
            Reporter:
            awilkinson Andy Wilkinson
            Last updater:
            Spring Issues Spring Issues
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: