Expected mime type application/octet-stream but got text/html.

来源:互联网 发布:红帽系统yum源 编辑:程序博客网 时间:2024/05/21 17:48

在运行solr技术的工程的时候出现Expected mime type application/octet-stream but got text/html.错误


网上找的原因有:

在使用Tomcat部署Solr后,Collection1的地址为:http://ip:8080/solr/#/collection1,但使用SolrJ进行索引的时候,应该使用http://ip:8080/solr/collection1,即无中间的#号。

即正确代码为:

  1. String serverUrl = (args != null && args.length > 0) ? args[0]  
  2.                 : "http://ip:8080/solr/collection1";  
错误代码为:
  1. String serverUrl = (args != null && args.length > 0) ? args[0]  
  2.                 : "http://ip:8080/solr/#/collection1"


但是我的是因为solrServer配置出错,正确的应该是:
    <bean id="httpSolrServer" class="org.apache.solr.client.solrj.impl.HttpSolrServer">
        <constructor-arg index="0" value="http://localhost:8081/solr"/>
    </bean>

同时应该开启tomcat服务器中的startup.bat。这样子solr才能访问成功

阅读全文
0 0