This article is a mirror article of machine translation, please click here to jump to the original article.

View: 29172|Reply: 1

[Source] Java FeignClient Interface exception solution for multiple identical service names

[Copy link]
Posted on 9/14/2021 6:05:15 PM | | | |
Spring Cloud uses OpenFeign for microservice communication, and the error is reported as follows when the same service name is different from the interface:

Description:

The bean 'itsvse. FeignClientSpecification' could not be registered. A bean with that name has already been defined and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true


Cause analysis

The values of the multiple FeignClient interfaces defined are all xxxx-server, and the bean names of Springboot 2.2.x are named according to the value (i.e., name) of the @FeignClient, resulting in the bean being already defined.


solution

Solution 1: According to the prompt of the error, add the following configuration:



Solution 2, when defining FeignClient, define the contextId attribute at the same time, which will be included in the beanName rule, and there will be no exceptions where the bean has been defined.

(End)




Previous:Windows does not have a browser to obtain an external (egress) IP address
Next:Detailed explanation of common functional interfaces (delegates) in Java
 Landlord| Posted on 9/22/2021 3:28:34 PM |

GET must not have a request body


feign must add @RequestParam when using okhttp3's Get method to request an interface.Controllers can be added without being added

Examples include:



Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com