简体   繁体   English

spring-data-solr创建错误的URL。 两次添加核心名称

[英]spring-data-solr creating wrong url. Adding core name twice

In my spring-data-solr project, Im getting 在我的spring-data-solr项目中,我正在

org.springframework.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. UncategorizedSolrException :来自http:// localhost:8983 / solr / preauth的服务器错误:预期的mime类型为application / octet-stream,但有text / html。

The URL that gets generated while any operation is wrong. 任何操作错误时生成的URL。 It contains the core name twice. 它包含两次核心名称。

The Stack Trace: 堆栈跟踪:

<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>

The solr url contains the core name " preauth " twice. solr URL包含两次核心名称“ preauth ”。

My dependency: 我的依赖:

<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-solr</artifactId>
<version>2.1.0.RELEASE</version>
</dependency>

My Configuration: 我的配置:

@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;
    }

}

My Document bean: 我的文档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...
.....

My Repository: 我的资料库:

public interface SolrPreauthRepository extends SolrCrudRepository<Preauth, Integer> {

}

This is due to a bug in the current version of Spring Data Solr. 这是由于Spring Data Solr当前版本中的错误所致。

A potential workaround is updating your Spring Boot version in your build script to a previous version where this isn't the case ie v1.4.3.RELEASE. 一个可能的解决方法是将构建脚本中的Spring Boot版本更新为以前的版本,而不是以前的版本,即v1.4.3.RELEASE。

Example for Gradle: 摇篮示例:

buildscript {
    ext {
        springBootVersion = '1.4.3.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

More bug info: https://jira.spring.io/browse/DATASOLR-364 更多错误信息: https : //jira.spring.io/browse/DATASOLR-364

it is a known bug. 这是一个已知的错误。 they have fixed it but it is not released yet. 他们已修复它,但尚未发布。 you can use a snapshot release: 您可以使用快照版本:

repositories {
    maven { 
        url "https://repo.spring.io/libs-snapshot" 
    }
}


dependencies {
    compile('org.springframework.data:spring-data-solr:2.2.0.DATASOLR-364-SNAPSHOT')
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM