solrj 7.xExpected mime type application/octet-stream but got text/html.

历览千载书,时时见遗烈。这篇文章主要讲述solrj 7.xExpected mime type application/octet-stream but got text/html.相关的知识,希望能为你提供帮助。
出现这种情况是因为baseurl填写错误,最开始的时候我写的是用tomcat启动后浏览器中访问solr的地址

solrj 7.xExpected mime type application/octet-stream but got text/html.

文章图片

结果就出现了如题的异常,当然提示的是404,还有可能提示405,Method not allowed,method post is not supported等等
查看源码后发现给出的实例是这种格式http://ip:port/solr/+core,修改后重新测试正常
 
1@Test 2public void saveOrUpdate() throws Exception{ 3//url应为http://ip:port/solr/+core 4HttpSolrClient solrClient = new HttpSolrClient.Builder("http://127.0.0.1:8080/solr/solrcore1").build(); 5SolrInputDocument document = new SolrInputDocument(); 6document.addField("id","test001"); 7document.addField("name_ik","my first solr client"); 8solrClient.add(document); 9solrClient.commit(); 10}

 
solrj 7.xExpected mime type application/octet-stream but got text/html.

文章图片

【solrj 7.xExpected mime type application/octet-stream but got text/html.】 

    推荐阅读