我正在尝试使用以下代码连接到solr服务器:
SolrServer solr = new HttpSolrServer("http://localhost:8080/solr-all");
SolrQuery query = new SolrQuery();
query.setQuery("*:*");
query.setRows(10);
query.setStart(0);
QueryResponse response = solr.query(query);
System.out.println(response);
但我得到这个错误:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" org.apache.solr.client.solrj.impl.HttpSolrServer$RemoteSolrException: Server at http://localhost:8080/solr-all returned non ok status:401, message:Unauthorized
我真的不知道如何设置用户名和密码,我在网上找到了许多使用htttpclient
的例子,但没有一个对我有效。
3条答案
按热度按时间d5vmydt91#
要设置凭据,请执行以下操作:
查类似讨论:
Solr 4 with basic authentication
zxlwwiss2#
解决方案配置:
抢先验证侦听器:
Solr控制器:
x6492ojm3#
您能否检查Slf4j在运行时是否可用?
表示您的程式码在执行阶段需要这个类别。