-
Notifications
You must be signed in to change notification settings - Fork 471
ConverterRegisteringWebMvcConfigurer#0: defined in null, overriding RestTemplate #779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You may be rigging together a little differently than expected. The idea of I don't know what the You might want to back off of registering a RestTemplate into the app context and instead, autowire the RestTemplateBuilder into the target, building your RestTemplate there. |
Thanks for your reply @gregturn . I would really like to do what you explained (it was the first thing I did), but I arrived to that weird solution because of this:
In short: this is a multi-tenant application and in Thanks |
I'm honestly not sure how to disentangle your situation. You are mixing together a lot of technologies and the result is we can't track down a circular dependency of epic proportion. Also, since you are using Spring Data REST, the problem may have nothing to do with Spring HATEOAS but instead custom code in Spring Data REST. |
@drenda Hello, APPLICATION FAILED TO START Description: Field restTemplate in com.mycompany.services.rest.RestService required a single bean, but 2 were found: |
I think it is a bug in org.springframework.hateoas.config.HypermediaSupportBeanDefinitionRegistrar. When I debuged it, this class will be registered in two times. This error only occurs when Resttemplate is registered as Bean in ApplicationContext. See: org.springframework.hateoas.config.ConverterRegisteringBeanPostProcessor#postProcessBeforeInitialization The postProcessBeforeInitialization tries to find the configurer and get this bean two times. I fixed it very quick&dirty, by editing the registerSourcedBeanDefinition method:
} ` @gregturn will this help to fix this bug? |
I've had this problem as well, and I think I solved it by adding EDIT: Sorry, that wasn't it. That was for a conflict involving an @Bean
public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder, MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter) {
RestTemplate restTemplate = restTemplateBuilder.build();
mappingJackson2HttpMessageConverter.setSupportedMediaTypes(Arrays.asList(APPLICATION_JSON, APPLICATION_OCTET_STREAM));
restTemplate.getMessageConverters().add(mappingJackson2HttpMessageConverter);
return restTemplate;
} |
Facing similiar problem with below Exception Field s2sClient_ in com.xxx.yyy.xxx.Class required a single bean, but 8 were found: 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 |
Solved! I excluded a repeated declaration of ConverterRegisteringWebMvcConfigurer by removing redundant dependency declaration. |
@fabiohenriquebayma could you Kindly explain the redundancy dependency you removed? I need a fix for the issue as well. |
I just removed the declaration of spring-boot-starter-web in favor of spring-hateoas. spring-hateoas has spring-web. I could also exclude spring-web from heteoas in favor of spring-boot-starter-web. I believe it is case-by-case. |
I solved the problem by using RestTemplateBuilder instead of RestTemplate.
|
I'm facing a weird exception involving ConverterRegisteringWebMvcConfigurer.
I posted my problem here.
I tried all things I could think about without any luck. I'm not sure it's a bug, but for sure the error message is quite weird:
Field restTemplate in cloud.test.server.rest.clients.TenantRestClient required a single bean, but 2 were found: - org.springframework.hateoas.config.ConverterRegisteringWebMvcConfigurer#0: defined in null - org.springframework.hateoas.config.ConverterRegisteringWebMvcConfigurer#1: defined in null
As described in my question, my code works until Spring Boot 2.0.3.
The text was updated successfully, but these errors were encountered: