在我的 spring-data-solr 项目中, 我得到了
org.springframework.data.solr.UncategorizedSolrException: Error from server at http://localhost:8983/solr/preauth: Expected mime type application/octet-stream but got text/html.
任何操作错误时生成的 URL。它包含两次核心名称。
堆栈跟踪:
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 404 Not Found</title>
</head>
<body><h2>HTTP ERROR 404</h2>
<p>Problem accessing /solr/preauth/preauth/select. Reason:
<pre> Not Found</pre></p>
</body>
</html>
solr url 两次包含核心名称“preauth”。
我的依赖:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-solr</artifactId>
<version>2.1.0.RELEASE</version>
</dependency>
我的配置:
@Configuration
@EnableSolrRepositories(basePackages = { "com.abi.claimbook" }, multicoreSupport = true)
public class SolrConfig {
@Value("${solr.claimbook.url}")
private String host;
@Bean
public SolrClient solrClient() throws Exception {
HttpSolrClientFactoryBean factory = new HttpSolrClientFactoryBean();
factory.setUrl(host);
factory.afterPropertiesSet();
SolrClient client = factory.getSolrClient();
return client;
}
@Bean
public SolrTemplate solrTemplate(SolrClient solrClient) throws Exception {
SolrTemplate solrTemplate = new SolrTemplate(solrClient);
return solrTemplate;
}
}
我的文档 bean:
@SolrDocument(solrCoreName = "preauth")
public class Preauth {
@Id
@Indexed
@Field
private Integer preauthId;
@Indexed
@Field
private String patientName;
@Indexed
@Field
private String alNumber;
.....
Getters and setters...
.....
我的仓库:
public interface SolrPreauthRepository extends SolrCrudRepository<Preauth, Integer> {
}
最佳答案
这是由于当前版本的 Spring Data Solr 中的一个错误。
一个潜在的解决方法是将构建脚本中的 Spring Boot 版本更新为以前的版本,但情况并非如此,即 v1.4.3.RELEASE。
Gradle 示例:
buildscript {
ext {
springBootVersion = '1.4.3.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
关于java - spring-data-solr 创建了错误的 url。两次添加核心名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42207148/