文章导读
大家好,我是顺亿。今天我们来聊聊SpringBoot如何与Solr集成,从配置到测试,一步步带你入门。
正文部分
首先,确保你的Solr已经配置完毕,并且已经含有数据。
搭建工程
接下来,开始搭建你的SpringBoot工程。
编写配置文件
找到你的resources目录下的application.properties文件,根据你的环境选择配置单机版或集群版。
单机版配置
spring.data.solr.host=http://192.168.10.101:8080/solr/collection1
集群版配置
spring.data.solr.zk-host=192.168.10.88:2181,192.168.10.88:2182,192.168.10.88:2183
测试查询与分页
@Test
public void findPage() throws IOException, SolrServerException {
CloudSolrClient cloudSolrClient =(CloudSolrClient)solrClient;
cloudSolrClient.setDefaultCollection(
