This article does not speak SOLR related, only the integration, the Content list is as follows
1. Maven dependency coordinates
2. Application.properties Configuration
3. Java Config configuration
1. MAVEN coordinates
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-solr</artifactId>
</dependency>
2. Application.properties Configuration
Note that the spring.data.solr.core here is not provided by the framework and will be reminded in idea
# SOLR
Spring.data.solr.host=http://localhost:8080/solr
Spring.data.solr.core=collection1
3. Java Config configuration
Here is the main configuration of the Solrtemplate, by default, SOLR Starter is not to provide this bean.
The point of attention is that httpsolrserver to guide the package
Import Org.apache.solr.client.solrj.impl.HttpSolrServer;
Import Org.springframework.beans.factory.annotation.Value;
Import Org.springframework.context.annotation.Bean;
Import org.springframework.context.annotation.Configuration;
Import Org.springframework.data.solr.core.SolrTemplate;
Import Org.springframework.data.solr.core.convert.SolrJConverter;
@Configuration
public class Solrconfig {
@Value ("${spring.data.solr.host}")
Private String Solrhost;
@Value ("${spring.data.solr.core}")
Private String Solrcore;
/**
* Configuration Solrtemplate
*/
@Bean
Public Solrtemplate solrtemplate () {
Httpsolrserver solrserver = new Httpsolrserver (solrhost);
Solrtemplate template = new Solrtemplate (solrserver);
Template.setsolrcore (Solrcore);
Template.setsolrconverter (New Solrjconverter ());
return template;
}
}
Springboot Integrated Spring Data SOLR