Springboot Integrated Spring Data SOLR

Source: Internet
Author: User
Tags solr

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.