Solr 7.5 Expected mime type application/json but got text/plain.

阅读更多
SolrJ版本7.5,Solr版本7.5。查询测试代码如下:
        SolrClient solr = new HttpSolrClient.Builder(solrUrl).build();

        SolrQuery query=new SolrQuery();
        query.set("q","title:"+queryStr);
        query.set("wt","json");
        try {
            QueryResponse solrResponse=solr.query(query );
            SolrDocumentList results = solrResponse.getResults();
            System.out.println(results.toString());
        } catch (SolrServerException e) {
            e.printStackTrace();
        }


执行抛出异常信息:
org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException: Error from server at http://127.0.0.1:8983/solr/xxxxxx: Expected mime type application/json but got text/plain

经过一番苦苦搜索,原因居然出在 solr-7.5.0/server/solr/${core}/conf/solrconfig.xml
该配置文件中有如下配置:

    
    text/plain; charset=UTF-8


各位请注意看注释里面的那段话!!!
将text/plain 修改为 application/json 运行一切正常。

你可能感兴趣的:(solr,java)