> For the complete documentation index, see [llms.txt](https://jack80342.gitbook.io/spring-boot/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jack80342.gitbook.io/spring-boot/iv.-spring-boot-features/30.-working-with-nosql-technologies/30.5-solr/30.5.1-connecting-to-solr.md).

# 30.5.1 连接Solr

你可以注入一个自动配置的`SolrClient`实例。就像其他Spring beans那样，该实例默认使用`localhost:8983/solr`连接Solr服务器。下面的例子展示了怎样注入一个Solr bean：

```java
@Component
public class MyBean {

    private SolrClient solr;

    @Autowired
    public MyBean(SolrClient solr) {
        this.solr = solr;
    }

    // ...

}
```

如果你添加自己的`SolrClient`类型的`@Bean`，它将会替换默认实例。
