在運行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,即無中間的#號。
即正確代碼爲:
- String serverUrl = (args != null && args.length > 0) ? args[0]
- : "http://ip:8080/solr/collection1";
- String serverUrl = (args != null && args.length > 0) ? args[0]
- : "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才能訪問成功