package org.springblade.es.config; import org.springblade.es.service.ElasticsearchIndexInitializer; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.stereotype.Component; // 暂时关闭 //@Component public class ElasticsearchInitializer implements CommandLineRunner { private final ElasticsearchIndexInitializer indexInitializer; @Autowired public ElasticsearchInitializer(ElasticsearchIndexInitializer indexInitializer) { this.indexInitializer = indexInitializer; } @Override public void run(String... args) { String indexName = "your_index_name"; String mappingJson = "{\"properties\":{\"your_field\":{\"type\":\"text\"}}}"; indexInitializer.initializeIndex(indexName, mappingJson); } }