spring-cloud / spring-cloud-schema-registry

A schema registry implementation for Spring Cloud Stream
47 stars 28 forks source link

GeoJsonModule module is registered twice once I add `spring-cloud-stream-schema` #28

Open juliuskrah opened 4 years ago

juliuskrah commented 4 years ago

Spring Boot Version: 2.2.4.RELEASE Java Version: 11 Spring Cloud Version: Hoxton.SR1

I have registered a bean of Type GeoJsonModule

@Bean
com.fasterxml.jackson.databind.Module geoJsonModule() {
        var geoJsonModule = new GeoJsonModule();
                // Added these mixins for serialization. The module takes care of only deserialization
        geoJsonModule.setMixInAnnotation(GeoJsonPoint.class, GeoJsonMixins.GeoJsonPointMixin.class);
        geoJsonModule.setMixInAnnotation(GeoJsonMultiPoint.class, GeoJsonMixins.GeoJsonMultiPointMixin.class);
        geoJsonModule.setMixInAnnotation(GeoJsonLineString.class, GeoJsonMixins.GeoJsonLineStringMixin.class);
        geoJsonModule.setMixInAnnotation(GeoJsonPolygon.class, GeoJsonMixins.GeoJsonPolygonMixin.class);
        geoJsonModule.setMixInAnnotation(GeoJsonMultiLineString.class, GeoJsonMixins.GeoJsonMultiLineStringMixin.class);
        return geoJsonModule;
}

This works fine and I'm happy.

Now when I add spring-cloud-stream-schema another GeoJsonModule is registered and overriding the one I registered previously.

package org.springframework.data.mongodb.config;
public class GeoJsonConfiguration implements SpringDataJacksonModules {

    @Bean
    public GeoJsonModule geoJsonModule() {
        return new GeoJsonModule();
    }
}

This class does not have any of the Spring-Boot @Conditional* that I can override

juliuskrah commented 4 years ago

After explicitly setting my web-application type to reactive, this is no longer the case. The GeoJSON module is not getting registered twice.

spring:
  main:
    web-application-type: reactive

I suspect adding spring-cloud-stream-schema is setting the web application type to servlet.

sabbyanandan commented 4 years ago

@juliuskrah: The spring-cloud-stream-schema module has been moved to a standalone project, and it is not chained under Spring Cloud Stream anymore. More details here.

Please retry with the new project/release, and let us know if you continue to see issues with it.

juliuskrah commented 4 years ago

spring-cloud-stream-schema pulls in spring-web which causes issues for people using spring-webflux

I had to set

spring:
  main:
    web-application-type: reactive

... to turn this off.

Removing the dependency on spring-web also fixes this

<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-stream-schema</artifactId>
  <version>2.2.1.RELEASE</version>
  <exclusions>
    <exclusion>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </exclusion>
  </exclusions>
</dependency>

spring-cloud-stream-schema should have an optional dependency on spring-web

sabbyanandan commented 4 years ago

@tzolov: Let's investigate this locally with the dependencies supplied by @juliuskrah ^^.