Skip to content

Commit 4d7b03b

Browse files
committed
Polish contribution
Closes gh-8202
1 parent 31ed70e commit 4d7b03b

File tree

2 files changed

+70
-64
lines changed

2 files changed

+70
-64
lines changed

spring-boot-samples/spring-boot-sample-cache/README.adoc

Lines changed: 54 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ abstraction is supported by many caching libraries, including:
1515
* Generic provider based on `org.springframework.Cache` bean definition(s)
1616
1717
The sample defines a simple `CountryService` that caches countries by ISO code. When
18-
the application starts a client invokes the service with a random code every 500ms. You
19-
can look at the `/metrics` endpoint to review the cache statistics if your chosen
18+
the application starts a client invokes the service with a random code every 500ms.
19+
You can look at the `/metrics` endpoint to review the cache statistics if your chosen
2020
caching provider is supported.
2121

2222

@@ -26,30 +26,31 @@ The sample uses Spring's cache annotation. If you want to use the JSR-107 annota
2626
instead, simply add the `javax.cache:cache-api` dependency to the project. No further
2727
configuration is necessary.
2828

29-
NOTE: You can use the JSR-107 annotations with _any_ cache provider; a JSR-107 compliant
30-
cache provider is not necessary.
29+
NOTE: You can use the JSR-107 annotations with _any_ cache provider; a JSR-107
30+
compliant cache provider is not necessary.
3131

3232

3333

3434
== Using a different cache provider
3535
Initially, the project does not define any caching library so the abstraction works
36-
on simple `ConcurrentHashMap`-based caches. You can try out your favorite caching library
37-
as explained below.
36+
on simple `ConcurrentHashMap`-based caches. You can try out your favorite caching
37+
library as explained below.
3838

3939

4040

4141
=== JCache (JSR-107)
42-
If you want to configure your cache infrastructure via the standard, you need a compliant
43-
implementation and the JSR-107 api. You first need to add `javax.cache:cache-api` to your
44-
project. Then you could try the following:
42+
If you want to configure your cache infrastructure via the standard, you need a
43+
compliant implementation and the JSR-107 api. You first need to add
44+
`javax.cache:cache-api` to your project. Then you could try the following:
4545

4646
* `EhCache 3`: add `org.ehcache:ehcache`
4747
* `Hazelcast`: add `com.hazelcast:hazelcast`
4848
* `Infinispan`: add `org.infinispan:infinispan-jcache`
4949

50-
TIP: Certain cache providers do not create a default cache on-the-fly if it does not exist
51-
so you might need to update the sample to create the caches on startup or specify the
52-
location to the provider-specific file via the `spring.cache.jcache.config` property.
50+
TIP: Certain cache providers do not create a default cache on-the-fly if it does not
51+
exist so you might need to update the sample to create the caches on startup or
52+
specify the location to the provider-specific file via the
53+
`spring.cache.jcache.config` property.
5354

5455
NOTE: Any other JSR-107 compliant provider is also supported but Spring Boot may not
5556
offer a dependency management entry for it. You will have to add it with the version
@@ -59,59 +60,73 @@ of the library that you want to use.
5960

6061
=== EhCache 2.x
6162
Simply add the `net.sf.ehcache:ehcache` dependency to the project. Since there is a
62-
default `ehcache.xml` configuration file at the root of the classpath, it is automatically
63-
used to configure the underlying `CacheManager`. Note that EhCache 3 uses a different
64-
format and doesn't default to `ehcache.xml` anymore. Check
65-
http://www.ehcache.org/documentation/3.0/xml.html[the documentation] for more details.
63+
default `ehcache.xml` configuration file at the root of the classpath,
64+
it is automatically used to configure the underlying `CacheManager`.
65+
Note that EhCache 3 uses a different format and doesn't default to `ehcache.xml`
66+
anymore. Check http://www.ehcache.org/documentation/3.0/xml.html[the documentation]
67+
for more details.
68+
69+
TIP: Run sample cache application using EhCache with
70+
`$mvn spring-boot:run -Pehcache2`.
6671

67-
Run sample cache application using EhCache with `$mvn -P ehcache spring-boot:run`
6872

6973

7074
=== Hazelcast
71-
Both `com.hazelcast:hazelcast` and `com.hazelcast:hazelcast-spring` should be added to
72-
the project to enable support for Hazelcast. Since there is a default `hazelcast.xml`
73-
configuration file at the root of the classpath, it is used to automatically configure
74-
the underlying `HazelcastInstance`.
75+
Both `com.hazelcast:hazelcast` and `com.hazelcast:hazelcast-spring` should be added
76+
to the project to enable support for Hazelcast. Since there is a default
77+
`hazelcast.xml` configuration file at the root of the classpath, it is used to
78+
automatically configure the underlying `HazelcastInstance`.
79+
80+
TIP: Run sample cache application using Hazelcast with
81+
`$mvn spring-boot:run -Phazelcast`.
7582

76-
Run sample cache application using Hazelcast with `$mvn -P hazelcast spring-boot:run`
7783

7884

7985
=== Infinispan
8086
Add the `org.infinispan:infinispan-spring4-embedded` dependency to enable support for
81-
Infinispan. There is no default location that Infinispan uses to look for a config file
82-
so if you don't specify anything it will bootstrap on a hardcoded default. You can set
83-
the `spring.cache.infinispan.config` property to use the provided `infinispan.xml`
84-
configuration instead.
87+
Infinispan. There is no default location that Infinispan uses to look for a config
88+
file so if you don't specify anything it will bootstrap on a hardcoded default. You
89+
can set the `spring.cache.infinispan.config` property to use the provided
90+
`infinispan.xml` configuration instead.
91+
92+
TIP: Run sample cache application using Hazelcast with
93+
`$mvn spring-boot:run -Pinfinispan`.
8594

86-
Run sample cache application using Infinispan with `$mvn -P infinispan spring-boot:run`
8795

8896

8997
=== Couchbase
90-
Add the `java-client` and `couchbase-spring-cache` dependencies and make sure that you
91-
have setup at least a `spring.couchbase.bootstrap-hosts` property.
98+
Add the `java-client` and `couchbase-spring-cache` dependencies and make sure that
99+
you have setup at least a `spring.couchbase.bootstrap-hosts` property.
100+
101+
TIP: Run sample cache application using Hazelcast with
102+
`$mvn spring-boot:run -Pcouchbase`.
92103

93-
Start a Couchbase server, then run the sample cache application using Couchbase with `$mvn -P couchbase spring-boot:run`
94104

95105

96106
=== Redis
97-
Add the `spring-boot-starter-data-redis` and make sure it is configured properly (by default,
98-
a redis instance with the default settings is expected on your local box).
107+
Add the `spring-boot-starter-data-redis` and make sure it is configured properly (by
108+
default, a redis instance with the default settings is expected on your local box).
109+
110+
TIP: Run sample cache application using Hazelcast with
111+
`$mvn spring-boot:run -Predis`.
99112

100-
Start a Redis server, then run the sample cache application using Redis with `$mvn -P redis spring-boot:run`
101113

102114

103115
=== Caffeine
104116
Simply add the `com.github.ben-manes.caffeine:caffeine` dependency to enable support
105117
for Caffeine. You can customize how caches are created in different ways, see
106118
`application.properties` for an example and the documentation for more details.
107119

108-
Run sample cache application using Caffeine with `$mvn -P caffeine spring-boot:run`
120+
TIP: Run sample cache application using Hazelcast with
121+
`$mvn spring-boot:run -Pcaffeine`.
122+
109123

110124

111125
=== Guava
112-
Spring Boot does not provide any dependency management for _Guava_ so you'll have to add
113-
the `com.google.guava:guava` dependency with a version. You can customize how caches are
114-
created in different ways, see `application.properties` for an example and the
115-
documentation for more details.
126+
Spring Boot does not provide any dependency management for _Guava_ so you'll have to
127+
add the `com.google.guava:guava` dependency with a version. You can customize how
128+
caches are created in different ways, see `application.properties` for an example and
129+
the documentation for more details.
116130

117-
Run sample cache application using Guava with `$mvn -P guava spring-boot:run`
131+
TIP: Run sample cache application using Hazelcast with
132+
`$mvn spring-boot:run -Pguava`.

spring-boot-samples/spring-boot-sample-cache/pom.xml

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@
4949
</plugins>
5050
</build>
5151
<profiles>
52-
<!-- JCache API (JSR-107 support) -->
53-
<!-- Include with any of the caching providers below using, e.g. `$mvn -P jcache,hazelcast spring-boot:run` -->
5452
<profile>
5553
<id>jcache</id>
5654
<dependencies>
@@ -60,7 +58,6 @@
6058
</dependency>
6159
</dependencies>
6260
</profile>
63-
<!-- mvn -P caffeine spring-boot:run -->
6461
<profile>
6562
<id>caffeine</id>
6663
<dependencies>
@@ -70,8 +67,6 @@
7067
</dependency>
7168
</dependencies>
7269
</profile>
73-
<!-- Start Couchbase server, then... -->
74-
<!-- mvn -P couchbase spring-boot:run -->
7570
<profile>
7671
<id>couchbase</id>
7772
<dependencies>
@@ -85,39 +80,28 @@
8580
</dependency>
8681
</dependencies>
8782
</profile>
88-
<!-- mvn -P ehcache spring-boot:run -->
8983
<profile>
90-
<id>ehcache</id>
84+
<id>ehcache2</id>
9185
<dependencies>
9286
<dependency>
9387
<groupId>net.sf.ehcache</groupId>
9488
<artifactId>ehcache</artifactId>
9589
</dependency>
9690
</dependencies>
9791
</profile>
98-
<!-- Start a Ehcache server, then... -->
99-
<!-- mvn -P org-ehcache spring-boot:run -->
10092
<profile>
101-
<id>org-ehcache</id>
93+
<id>ehcache</id>
10294
<dependencies>
10395
<dependency>
104-
<groupId>org.ehcache</groupId>
105-
<artifactId>ehcache</artifactId>
96+
<groupId>javax.cache</groupId>
97+
<artifactId>cache-api</artifactId>
10698
</dependency>
107-
</dependencies>
108-
</profile>
109-
<!-- mvn -P guava spring-boot:run -->
110-
<profile>
111-
<id>guava</id>
112-
<dependencies>
11399
<dependency>
114-
<groupId>com.google.guava</groupId>
115-
<artifactId>guava</artifactId>
116-
<version>18.0</version>
100+
<groupId>org.ehcache</groupId>
101+
<artifactId>ehcache</artifactId>
117102
</dependency>
118103
</dependencies>
119104
</profile>
120-
<!-- mvn -P hazelcast spring-boot:run -->
121105
<profile>
122106
<id>hazelcast</id>
123107
<dependencies>
@@ -131,7 +115,6 @@
131115
</dependency>
132116
</dependencies>
133117
</profile>
134-
<!-- mvn -P infinispan spring-boot:run -->
135118
<profile>
136119
<id>infinispan</id>
137120
<dependencies>
@@ -145,8 +128,6 @@
145128
</dependency>
146129
</dependencies>
147130
</profile>
148-
<!-- Start a Redis Server ($. <redis-install>/src/redis-server), then... -->
149-
<!-- mvn -P redis spring-boot:run -->
150131
<profile>
151132
<id>redis</id>
152133
<dependencies>
@@ -156,5 +137,15 @@
156137
</dependency>
157138
</dependencies>
158139
</profile>
140+
<profile>
141+
<id>guava</id>
142+
<dependencies>
143+
<dependency>
144+
<groupId>com.google.guava</groupId>
145+
<artifactId>guava</artifactId>
146+
<version>18.0</version>
147+
</dependency>
148+
</dependencies>
149+
</profile>
159150
</profiles>
160151
</project>

0 commit comments

Comments
 (0)