I need to inject two different objectMapper (Jackson2ObjectMapperBuilder) config on two versions of my controller, I have tried many examples, but with webflux they don't works (with webMvc work fine).
@RestController
@RequestMapping("/v1")
public class ControllerV1 implements IController {
...
}
@RestController
@RequestMapping("/v2")
public class ControllerV2 implements IController {
...
}
@EnableReactiveMongoRepositories
public class Config extends AbstractReactiveMongoConfiguration {
@Override
public MongoClient reactiveMongoClient() {
...
}
@Primary
@Bean(name = "objectMapperV1")
public Jackson2ObjectMapperBuilder v1objectMapperBuilder() {
Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
builder.propertyNamingStrategy(PropertyNamingStrategy.LOWER_CAMEL_CASE);
...
return builder;
}
@Bean(name = "objectMapperV2")
public Jackson2ObjectMapperBuilder v2objectMapperBuilder() {
Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
builder.propertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
...
return builder;
}
}
The only mapper used is the @Primary, how to set by configuration the v2objectMapperBuilder in ControllerV2?
ps: if inject v2objectMapperBuilder in ControllerV2 and use directly obviously works, but I don't want this.