在一个服务中,我在单独的文件中定义了2个配置,如下所示:
@Configuration
public class Config1 {
@Bean
public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) {
return restTemplateBuilder.setConnectTimeout(1000000).setReadTimeout(1000000).build();
}
}
@Configuration
public class ElasticsearchConfig {
@Bean(destroyMethod="close")
public RestHighLevelClient client() {
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(user, pass));
RestClientBuilder builder = RestClient.builder(new HttpHost(elasticsearchHost,9200,"http")).setHttpClientConfigCallback(
httpClientBuilder -> httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider));
return new RestHighLevelClient(builder);
}
}
我在调用rest模板交换时看到了一些意想不到的行为,这两个bean的创建是否相互干扰?为什么?
暂无答案!
目前还没有任何答案,快来回答吧!