Error 405 HTTP method POST is not supported by this URL 的解决办法

问题概述

在项目开发过程中,使用到了企业搜索引擎 Solr 服务,客户端通过 Apache-SolrJ 连接到远程Solr服务器,但是在编写测试单元时,遇到了个不大不小的BUG,总是连接不上,反复的检查各个配置,发现都是正确的,再测试,再查看错误信息:“ Error 405 HTTP method POST is not supported by this URL ”,其大概意思说明了当前URL是不被支持的格式。

部分截图如下:

Error 405 HTTP method POST is not supported by this URL 的解决办法_第1张图片

 

具体信息如下:

org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException: Error from server at http://192.168.159.159:8080/solr/#/aiyou_01_core: Expected mime type application/octet-stream but got text/html. 


Error 405 HTTP method POST is not supported by this URL

HTTP ERROR 405

Problem accessing /solr/index.html. Reason:

    HTTP method POST is not supported by this URL

at org.apache.solr.client.solrj.impl.HttpSolrClient.executeMethod(HttpSolrClient.java:620) at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:262) at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:245) at org.apache.solr.client.solrj.SolrRequest.process(SolrRequest.java:211) at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:177) at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:138) at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:156) at com.huazai.b2c.aiyou.test.solrj.TSolrjClient.addDocument(TSolrjClient.java:43) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)

 

 

解决办法

在错误信息中已知,是URL不被支持,错误的,但是一般都喜欢Ctrl + C/V,往往就会忽略了一些细节,如特殊符号,

修改前(错误的路径):http://192.168.159.159:8080/solr/#/aiyou_01_core

修改后(正确的路径):http://192.168.159.159:8080/solr/aiyou_01_core

 

这儿博主直接将Solr的core的路径复制到了里面,是不行的,因为里面夹带了一个特殊符号“ # ”,其主要问题是在通过SolrJ访问远程Solr服务器时,路径中不能加 “ # ” 的符号,取消掉就可以了,

解决后如下图:

Error 405 HTTP method POST is not supported by this URL 的解决办法_第2张图片

 

 

 

 


 好了,关于 Error 405 HTTP method POST is not supported by this URL  的解决办法 就写到这儿了,如果还有什么疑问或遇到什么问题欢迎扫码提问,也可以给我留言哦,我会一一详细的解答的。 
歇后语:“ 共同学习,共同进步 ”,也希望大家多多关注CSND的IT社区。


作       者: 华    仔
联系作者: [email protected]
来        源: CSDN (Chinese Software Developer Network)
原        文: https://blog.csdn.net/Hello_World_QWP/article/details/98198715
版权声明: 本文为博主原创文章,请在转载时务必注明博文出处!

你可能感兴趣的:(Solr,Java,HttpSolrClient,Error,Solr_Linux)