spring_reference/IV. Spring Boot features/29.4.1. Connecting to Solr.md

18 lines
469 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

### 29.4.1. 连接Solr
你可以像其他Spring beans一样注入一个自动配置的SolrServer实例。默认情况下该实例将尝试使用`localhost:8983/solr`连接一个服务器。
```java
@Component
public class MyBean {
private SolrServer solr;
@Autowired
public MyBean(SolrServer solr) {
this.solr = solr;
}
// ...
}
```
如果你添加一个自己的SolrServer类型的@Bean它将会替换默认的。