升级框架版本后spring-data-elasticsearch repository操作报错
java.lang.NoSuchFieldError: INDEX_CONTENT_TYPE
at org.springframework.data.elasticsearch.core.RequestFactory.indexRequest(RequestFactory.java:623)
at org.springframework.data.elasticsearch.core.RequestFactory.lambda$bulkRequest$1(RequestFactory.java:248)
at java.util.ArrayList.forEach(ArrayList.java:1257)
at org.springframework.data.elasticsearch.core.RequestFactory.bulkRequest(RequestFactory.java:245)
原因是springboot版本和spring-data-elasticsearch版本不对应
springboot:2.6.7
spring-data-elasticsearch:4.4.0
解决:
将spring-data-elasticsearch版本降低到4.3.4就好了
文章来源:https://www.toymoban.com/news/detail-513530.html
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId>
<version>4.3.4</version>
</dependency>
import com.lyh.api.entity.article.Hotel;
import org.springframework.data.repository.PagingAndSortingRepository;
public interface HotelRepository extends PagingAndSortingRepository<Hotel, Integer> {
}
@Autowired
HotelRepository repository;
@Test
public void test5 (){
List<Hotel> hotels = hotelService.getAllList();
for (Hotel h:hotels
) {
h.setSsuggest(new Completion(Arrays.asList(h.getBrand(),h.getBusiness()).toArray(new String[Arrays.asList(h.getBrand(),h.getBusiness()).size()])));
}
repository.saveAll(hotels);
}
怎么荔枝文章来源地址https://www.toymoban.com/news/detail-513530.html
到了这里,关于elastic报错java.lang.NoSuchFieldError: INDEX_CONTENT_TYPE的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!