0
有没有使用带有多核支持的存储库的solr来设置spring数据的详细和完整的解释?如何为多个内核配置带有存储库的Spring Data Solr
有没有使用带有多核支持的存储库的solr来设置spring数据的详细和完整的解释?如何为多个内核配置带有存储库的Spring Data Solr
需要用于弹簧数据Solr的唯一依赖是
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-solr</artifactId>
<version>1.5.2.RELEASE</version>
</dependency>
它下载solrj依赖和这不能与更高版本solrj的覆盖。 另外它总是最好使用HttpSolrServer而不是EmbeddedSolrServer,这是我们将要使用的。
Configuration类应该是这样的:
@Configuration
@EnableSolrRepositories(value = "com.package.",multicoreSupport = true)
public class SolrConfig
{
@Bean
public SolrServer solrServer() throws Exception
{
HttpSolrServerFactoryBean f = new HttpSolrServerFactoryBean();
f.setUrl("http://localhost:8983/solr");
f.afterPropertiesSet();
return f.getSolrServer();
}
@Bean
public SolrTemplate solrTemplate(SolrServer solrServer) throws Exception
{
return new SolrTemplate(solrServer());
}
}
文档实体应包含有关其所属
@SolrDocument(solrCoreName = "core1")
public class Document1
{
@Id
@Field
private String id;
/**other attributes**/
}
其核心信息的其他文件应
@SolrDocument(solrCoreName = "core2")
public class Document2
{
@Id
@Field
private String id;
/**other attributes**/
}
现在最好的部分是你已经完成了。只需在普通的旧的方式建立信息库做的伎俩
public interface SolrCore1Repository extends SolrCrudRepository<Document1,String>
{
// optional code
}
其他回购就像
public interface SolrCore2Repository extends SolrCrudRepository<Document2,String>
{
// optional code
}
一旦Solr的是在指定的网址中运行,并根据POJO有田,你是完成。