【问题标题】:Spring-Data-Solr How to provide authentication dataSpring-Data-Solr 如何提供认证数据
【发布时间】:2014-07-02 20:54:12
【问题描述】:

我如何为 spring data solr 服务器提供身份验证数据? 这是我的配置

 <solr:solr-server id="solrServer" url="http://xxxxxxxx:8983/solr" />

  <bean id="solrTemplate" class="org.springframework.data.solr.core.SolrTemplate" scope="singleton">
    <constructor-arg ref="solrServer" />
  </bean>

  <bean id="searchRepository" class="com.bankofamerica.atmtech.repository.SolrJournalRepository">
    <property name="solrOperations" ref="solrTemplate" />
  </bean>

   <bean id="App" class="App">
    <property name="repo" ref="searchRepository" />
  </bean>

我没有看到任何可以设置的属性。

【问题讨论】:

    标签: spring-data-solr


    【解决方案1】:

    你不能直接设置Credentials,必须通过工厂。

    @Bean
    SolrTemplate solrTemplate() {
      return new SolrTemplate(solrServerFactory());
    }
    
    @Bean
    SolrServerFactory solrServerFactory() {
    
      Credentials credentials = new UsernamePasswordCredentials("foo", "bar");
      return new HttpSolrServerFactory(solrServer(), "collection1", credentials , "BASIC");
    }
    
    @Bean
    SolrServer solrServer() {
      return new HttpSolrServer("http://localhost:8983/solr");
    }
    

    我猜想某种SolrAuthenticationProvider 如果出现在应用程序上下文中,那么在这种情况下是有意义的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-09-19
      • 1970-01-01
      • 2017-11-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多