forked from 99246255/SpringBoot-Solr
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolrConfig.java
More file actions
42 lines (32 loc) · 1.11 KB
/
SolrConfig.java
File metadata and controls
42 lines (32 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
* Project Name:chenxun-solr
* File Name:SolrConfig.java
* Package Name:com.chenxun.solr.config
* Date:2016年8月20日下午3:11:32
* Copyright (c) 2016, www midaigroup com Technology Co., Ltd. All Rights Reserved.
*
*/
package com.solr.config;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
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.repository.config.EnableSolrRepositories;
@Configuration
@EnableSolrRepositories(basePackages = { "com.solr" }, multicoreSupport = true)
public class SolrConfig {
@Value("${spring.data.solr.host}")
private String url;
@Bean
public SolrClient solrClient() {
return new HttpSolrClient(url);
}
@Bean
public SolrTemplate solrTemplate() throws Exception {
SolrTemplate solrTemplate = new SolrTemplate(solrClient());
// solrTemplate.setSolrConverter(solrConverter);
return solrTemplate;
}
}