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

在運行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才能訪問成功

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章