@@ -13,9 +13,9 @@ Auditing, health and metrics gathering can be automatically applied to your appl
...
@@ -13,9 +13,9 @@ Auditing, health and metrics gathering can be automatically applied to your appl
[[production-ready-enabling]]
[[production-ready-enabling]]
== Enabling production-ready features.
== Enabling production-ready features.
The https://github.com/spring-projects/spring-boot/tree/master/spring-boot-actuator[`spring-boot-actuator`] module provides all of Spring Boot'sproduction-ready
The {github-code}/spring-boot-actuator[`spring-boot-actuator`] module provides all of
http://redis.io/[Redis] is a cache, message broker and richly-featured key-value store. Spring Boot offers basic autoconfiguration for the https://github.com/xetorthio/jedis/[Jedis] client library and abstractions on top of it provided by https://github.com/spring-projects/spring-data-redis[Spring Data Redis]. There is a `spring-boot-starter-redis` ``Starter POM`` for collecting the dependencies in a convenient way.
http://redis.io/[Redis] is a cache, message broker and richly-featured key-value store.
Spring Boot offers basic auto-configuration for the https://github.com/xetorthio/jedis/[Jedis]
client library and abstractions on top of it provided by
https://github.com/spring-projects/spring-data-redis[Spring Data Redis]. There is a
`spring-boot-starter-redis` ``Starter POM'' for collecting the dependencies in a
convenient way.
[[boot-features-connecting-to-redis]]
[[boot-features-connecting-to-redis]]
==== Connecting to Redis
==== Connecting to Redis
You can inject an auto-configured `RedisConnectionFactory`, `StringRedisTemplate` or vanilla `RedisTemplate` instance as you would any other
You can inject an auto-configured `RedisConnectionFactory`, `StringRedisTemplate` or
Spring Bean. By default the instance will attempt to connect to a Redis server using
vanilla `RedisTemplate` instance as you would any other Spring Bean. By default the
`localhost:6379`:
instance will attempt to connect to a Redis server using `localhost:6379`:
[source,java,indent=0]
[source,java,indent=0]
----
----
@Component
@Component
public class MyBean {
public class MyBean {
private StringRedisTemplate template;
private StringRedisTemplate template;
@Autowired
@Autowired
public MyBean(StringRedisTemplate template) {
public MyBean(StringRedisTemplate template) {
...
@@ -1462,9 +1471,11 @@ Spring Bean. By default the instance will attempt to connect to a Redis server u
...
@@ -1462,9 +1471,11 @@ Spring Bean. By default the instance will attempt to connect to a Redis server u
}
}
----
----
If you add a `@Bean` of your own of any of the autoconfigured types it will replace the default
If you add a `@Bean` of your own of any of the auto-configured types it will replace the
(except in the case of `RedisTemplate` the exlcusion is based on the bean name "redisTemplate" not its type).
default (except in the case of `RedisTemplate` the exclusion is based on the bean name
If `commons-pool2` is on the classpath you will get a pooled connection factory by default.
``redisTemplate'' not its type). If `commons-pool2` is on the classpath you will get a
pooled connection factory by default.
[[boot-features-mongodb]]
[[boot-features-mongodb]]
...
@@ -1581,22 +1592,33 @@ TIP: For complete details of Spring Data MongoDB, including its rich object mapp
...
@@ -1581,22 +1592,33 @@ TIP: For complete details of Spring Data MongoDB, including its rich object mapp
technologies, refer to their http://projects.spring.io/spring-data-mongodb/[reference
technologies, refer to their http://projects.spring.io/spring-data-mongodb/[reference
documentation].
documentation].
[[boot-features-gemfire]]
[[boot-features-gemfire]]
=== Gemfire
=== Gemfire
https://github.com/spring-projects/spring-data-gemfire[Spring Data Gemfire] provides convenient Spring-friendly
https://github.com/spring-projects/spring-data-gemfire[Spring Data Gemfire] provides
tools for accessing the http://www.gopivotal.com/big-data/pivotal-gemfire#details[Pivotal Gemfire] data management platform.
convenient Spring-friendly tools for accessing the http://www.gopivotal.com/big-data/pivotal-gemfire#details[Pivotal Gemfire]
There is a `spring-boot-starter-data-gemfire` ``Starter POM`` for collecting the dependencies in a convenient way. There is currently no autoconfig support for Gemfire but you can enable Spring Data Repositories with a https://github.com/spring-projects/spring-data-gemfire/blob/master/src/main/java/org/springframework/data/gemfire/repository/config/EnableGemfireRepositories.java[single annotation].
data management platform. There is a `spring-boot-starter-data-gemfire` ``Starter POM''
for collecting the dependencies in a convenient way. There is currently no auto=config
support for Gemfire, but you can enable Spring Data Repositories with a
http://lucene.apache.org/solr/[Apache Solr] is a search engine. Spring Boot offers basic autoconfiguration for the solr client library and abstractions on top of it provided by https://github.com/spring-projects/spring-data-elasticsearch[Spring Data Solr]. There is a `spring-boot-starter-data-solr` ``Starter POM`` for collecting the dependencies in a convenient way.
http://lucene.apache.org/solr/[Apache Solr] is a search engine. Spring Boot offers basic
auto-configuration for the solr client library and abstractions on top of it provided by
https://github.com/spring-projects/spring-data-elasticsearch[Spring Data Solr]. There is
a `spring-boot-starter-data-solr` ``Starter POM'' for collecting the dependencies in a
convenient way.
[[boot-features-connecting-to-solr]]
[[boot-features-connecting-to-solr]]
==== Connecting to Solr
==== Connecting to Solr
You can inject an auto-configured `SolrServer` instance as you would any other
You can inject an auto-configured `SolrServer` instance as you would any other Spring
Spring Bean. By default the instance will attempt to connect to a server using
Bean. By default the instance will attempt to connect to a server using
`http://localhost:8983/solr`:
`http://localhost:8983/solr`:
[source,java,indent=0]
[source,java,indent=0]
...
@@ -1604,7 +1626,7 @@ Spring Bean. By default the instance will attempt to connect to a server using
...
@@ -1604,7 +1626,7 @@ Spring Bean. By default the instance will attempt to connect to a server using
@Component
@Component
public class MyBean {
public class MyBean {
private SolrServer solr;
private SolrServer solr;
@Autowired
@Autowired
public MyBean(SolrServer solr) {
public MyBean(SolrServer solr) {
...
@@ -1618,39 +1640,48 @@ Spring Bean. By default the instance will attempt to connect to a server using
...
@@ -1618,39 +1640,48 @@ Spring Bean. By default the instance will attempt to connect to a server using
If you add a `@Bean` of your own of type `SolrServer` it will replace the default.
If you add a `@Bean` of your own of type `SolrServer` it will replace the default.
[[boot-features-spring-data-solr-repositories]]
[[boot-features-spring-data-solr-repositories]]
==== Spring Data Solr repositories
==== Spring Data Solr repositories
Spring Data includes repository support for Apache Solr. As with the JPA repositories
Spring Data includes repository support for Apache Solr. As with the JPA repositories
discussed earlier, the basic principle is that queries are constructed for you
discussed earlier, the basic principle is that queries are constructed for you
automatically based on method names.
automatically based on method names.
In fact, both Spring Data JPA and Spring Data Solr share the same common
In fact, both Spring Data JPA and Spring Data Solr share the same common infrastructure;
infrastructure; so you could take the JPA example from earlier and, assuming that
so you could take the JPA example from earlier and, assuming that `City` is now a
`City` is now a `@SolrDocument` class rather than a JPA `@Entity`, it will work in the
`@SolrDocument` class rather than a JPA `@Entity`, it will work in the same way.
same way.
TIP: For complete details of Spring Data Solr, refer to their
TIP: For complete details of Spring Data Solr, including its rich object mapping
technologies, refer to their http://projects.spring.io/spring-data-solr/[reference
documentation].
[[boot-features-elasticsearch]]
[[boot-features-elasticsearch]]
=== Elasticsearch
=== Elasticsearch
http://www.elasticsearch.org/[Elastic Search] is a search engine. Spring Boot offers basic autoconfiguration for the solr client library and abstractions on top of it provided by [Spring Data Solr](https://github.com/spring-projects/spring-data-elasticsearch). There is a `spring-boot-starter-data-elasticsearch` ``Starter POM`` for collecting the dependencies in a convenient way.
http://www.elasticsearch.org/[Elastic Search] is an open source, distributed,
real-time search and analytics engine. Spring Boot offers basic auto-configuration for
the Elasticsearch and abstractions on top of it provided by
[Spring Data Elasticsearch](https://github.com/spring-projects/spring-data-elasticsearch).
There is a `spring-boot-starter-data-elasticsearch` ``Starter POM'' for collecting the
dependencies in a convenient way.
[[boot-features-connecting-to-elasticsearch]]
[[boot-features-connecting-to-elasticsearch]]
==== Connecting to Elasticsearch
==== Connecting to Elasticsearch
You can inject an auto-configured `ElasticsearchTemplate` or Elasticsearch `Client` instance as you would any other
You can inject an auto-configured `ElasticsearchTemplate` or Elasticsearch `Client`
Spring Bean. By default the instance will attempt to connect to a local in-memory server (a `NodeClient` in Elasticsearch
instance as you would any other Spring Bean. By default the instance will attempt to
terms), but you can switch to a remote server (i.e. a `TransportClient`) by setting `spring.data.elasticsearch.clusterNodes`
connect to a local in-memory server (a `NodeClient` in Elasticsearch terms), but you can
to a comma-separated "host:port" list.
switch to a remote server (i.e. a `TransportClient`) by setting
`spring.data.elasticsearch.clusterNodes` to a comma-separated "host:port" list.
[source,java,indent=0]
[source,java,indent=0]
----
----
@Component
@Component
public class MyBean {
public class MyBean {
private ElasticsearchTemplate template;
private ElasticsearchTemplate template;
@Autowired
@Autowired
public MyBean(ElasticsearchTemplate template) {
public MyBean(ElasticsearchTemplate template) {
...
@@ -1662,7 +1693,10 @@ to a comma-separated "host:port" list.
...
@@ -1662,7 +1693,10 @@ to a comma-separated "host:port" list.
}
}
----
----
If you add a `@Bean` of your own of type `ElasticsearchTemplate` it will replace the default.
If you add a `@Bean` of your own of type `ElasticsearchTemplate` it will replace the