I'm having this problem when I deploy the app in dev, the app runs locally, so I'm really confused:
The error says:
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of constructor in xxx.client.api.ClientApi required a single bean, but 2 were found:
\- xxx.xxx.ApiClient: defined in URL \[jar:file:/spring-web/lib/xxx-0.1.0-SNAPSHOT.jar!/xxx/rest/client/invoker/ApiClient.class\]
\- beanName: defined by method 'beanNamed' in class path resource \[xxx/config/RestClientConfiguration.class\]
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
The first instance is an autogenerated class in target (based in open api definition) that I use to create my beans, and my config is:
@Configuration
public class RestClientConfiguration {
@Bean("beanName")
@ConfigurationProperties(prefix = "xxx.common.rest.client.employee")
public RestClient beanName(final RestClientBuilder builder) {
return builder.build();
}
@Bean
@Primary
public ApiClient beanNamed(final @Qualifier("beanName") RestClient client) {
final ApiClient apiClient = new ApiClient(client);
apiClient.setBasePath(client.getBasePath());
return apiClient;
}
}
I tried with @EnableAutoConfiguration, same error at deplyoment. Any suggestions? I'm really stuck at this point.
I've tried with @EnableAutoConfiguration, removing and adding primary but I cannot change a lot of things because this project has a lot of autogenerated code.