rest client objectmapper 1 и 2 выглядят довольно одинаково:
Код: Выделить всё
@Configuration
public class My1JacksonConfig {
@Qualifier("my1ServicesObjectMapper").
@Bean("my1ServicesObjectMapper")
public ObjectMapper my1ServicesObjectMapper() {
return new ObjectMapper()
.findAndRegisterModules()
.enable(SerializationFeature.INDENT_OUTPUT)
.registerModule(new JavaTimeModule())
;
}
}
Код: Выделить всё
@Bean("my1WebClient")
public WebClient my1WebClient(@Qualifier("my1ServicesObjectMapper") ObjectMapper objectMapper) {
if (my1WebClient == null) {
bootstrappWebClient();
}
return my1WebClient;
}
< /code>
При запуске приложения он говорит: < /p>
2025-09-26T00:03:03.599708862+02:00 ERROR [] --- [main] org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter:
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of method mappingJackson2HttpMessageConverter in org.springframework.boot.autoconfigure.http.JacksonHttpMessageConvertersConfiguration$MappingJackson2HttpMessageConverterConfiguration required a single bean, but 2 were found:
- my1ServicesObjectMapper: defined by method 'my1ServicesObjectMapper' in class path resource [com/harry/potter/client/My1JacksonConfig.class]
- my2ServicesObjectMapper: defined by method 'my2ServicesObjectMapper' in class path resource [com/harry/potter/client/My2JacksonConfig.class]
This may be due to missing parameter name information
Action:
Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed
Ensure that your compiler is configured to use the '-parameters' flag.
You may need to update both your build tool settings as well as your IDE.
(See https://github.com/spring-projects/spring-framework/wiki/Spring-Framework-6.1-Release-Notes#parameter-name-retention)
, если я добавлю один объект @bean в приложение, делающее его первичным (первичным (
Код: Выделить всё
@PrimaryПодробнее здесь: https://stackoverflow.com/questions/797 ... t-properly
Мобильная версия