environment
<spring-boot.version>2.5.3</spring-boot.version>
<spring-cloud.version>2020.0.3</spring-cloud.version>
<spring-cloud-alibaba.version>2021.1</spring-cloud-alibaba.version>
report errors
Errors are reported during project startup, as follows:
2021-12-22 16:55:56.766 WARN 21922 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'oauth-client.FeignClientSpecification' defined in null: Cannot register bean definition [Generic bean: class [org.springframework.cloud.openfeign.FeignClientSpecification]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] for bean 'oauth-client.FeignClientSpecification': There is already [Generic bean: class [org.springframework.cloud.openfeign.FeignClientSpecification]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] bound.
2021-12-22 16:55:56.776 INFO 21922 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-12-22 16:55:56.799 ERROR 21922 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
The bean 'xxx-client.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
reason
Multiple interfaces in a project use @ feignclient to call the same service, which means that a service can only be used once with @ feignclient.
Solution:
1) Distinguish with ContextID
But I don’t know why it didn’t work
@FeignClient(value = “xxx-server”, contextId = “oauth-client”)
public interface OAuthClientFeignClient {
@GetMapping("/api/v1/oauth-clients/{clientId}")
Result<SysOauthClient> getOAuthClientById(@PathVariable String clientId);
}
2) Add the following code to the application.properties file.
#Allow the existence of multiple Feign calls to the same Service interface
spring.main.allow-bean-definition-overriding=true
3) Add the following code to the application.yml file.
spring:
main:
#Allow the existence of multiple Feign calls to the same Service interface
allow-bean-definition-overriding: true
The above code enables multiple interfaces to call the same service using @FeignClient.
Read More:
- Feign declarative call service feign.codec.DecodeException: Error while extracting response for type [class **] and…
- Failed to register bundle identifier. The app identifier “xxx” cannot be registered to your developm
- [Solved] Error: Could not open client transport with JDBC Uri
- Rendering Problems The following classes could not be instantiated: xml layout file could not be loaded
- feign.FeignException: status 404 reading XXXClient#XXMethod(String)
- [Solved] Chrome Error: The request client is not a secure context
- Error (17) solves the problem of losing the request header of multithread asynchronous feign call
- Kubernetes Error: Error in configuration: unable to read client-cert* unable to read client-key*
- [Solved] Error: failed to create deliver client: orderer client failed to connect to orderer.example.com:7050
- The authentication server Configurate NoClassDefFoundError Error (store client information in a JDBC-based database)
- [Solved] panic: proto: duplicate enum registered: raftpb.EntryType
- [Solved] CXF Call webservice Client Error: 2 counts of InaccessibleWSDLException
- mmdetection Error when running voc.py: KeyError: ‘NumClassCheckHook is already registered in hook‘
- [Solved] Fabric Start Network Error: Error: error getting endorser client for channel: endorser client failed to connect to
- [Solved] swiper Error: The requested module ‘react’ is expected to be of type CommonJS, which does not support named exports. CommonJS modules can be imported by importing the default export
- How to Solve creating bean with name ‘mappingjackson2httpmessageconverter’ error when elasticsearch advanced client starts‘
- [Solved] Error: Main class not found or could not be loaded com.jawasoft.
- C++ new types may not be defined in a return type Error?
- Postgis Install Error: could not load library “C:\……“:The specified module could not be found.
- [Solved] “Field pet in XXX.HelloController required a bean of type ‘XXX.Pet‘ that could not be found.“