在我的 spring-data-solr 项目中,我得到
org.springframework.data.solr.未分类的 Solr异常:来自的错误 http://localhost:8983/solr/preauth 的服务器:预期的 MIME 类型 应用程序/八进制流,但得到文本/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;
}
}
我的文档豆:
@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 引导版本更新到以前的版本,即 v1.4.3.RELEASE。
Gradle 示例:
buildscript {
ext {
springBootVersion = '1.4.3.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
更多错误信息:https://jira.spring.io/browse/DATASOLR-364
已知的错误。他们已经修复了它,但它还没有发布。您可以使用快照版本:
repositories {
maven {
url "https://repo.spring.io/libs-snapshot"
}
}
dependencies {
compile('org.springframework.data:spring-data-solr:2.2.0.DATASOLR-364-SNAPSHOT')
}