以前倒是没太注意,可能 版本问题吧,springboot2.1.17 redis &es springdata冲突,导致es 启动不了 actory method 'elasticsearchClient' threw exception; availableProcessors is already set to [4], rejecting [4
加入以下配置 其实 就是 在redis 之前加载
@Configuration
@Import(ElasticsearchAutoConfiguration.class)
@AutoConfigureBefore(RedisAutoConfiguration.class)
public class ElasticsearchConfig {
@PostConstruct
void init() {
System.setProperty("es.set.netty.runtime.available.processors", "false");
}
@Bean(name = "elasticsearchTemplate")
public ElasticsearchTemplate elasticsearchTemplate(Client client,
ElasticsearchConverter converter) {
try {
return new ElasticsearchTemplate(client, converter);
}
catch (Exception ex) {
throw new IllegalStateException(ex);
}
}
@Bean
public ElasticsearchConverter elasticsearchConverter(
SimpleElasticsearchMappingContext mappingContext) {
return new MappingElasticsearchConverter(mappingContext);
}
@Bean
public SimpleElasticsearchMappingContext mappingContext() {
return new SimpleElasticsearchMappingContext();
}
}
参考链接
https://blog.csdn.net/luluyo/article/details/92799193
https://www.jianshu.com/p/7a9dd59b6e59
elk