Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
fca192fa
Commit
fca192fa
authored
Jun 03, 2015
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spring-boot-starter-cache
Closes gh-3098
parent
0ad0ad4c
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
68 additions
and
19 deletions
+68
-19
pom.xml
spring-boot-dependencies/pom.xml
+5
-0
spring-boot-features.adoc
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
+3
-0
using-spring-boot.adoc
spring-boot-docs/src/main/asciidoc/using-spring-boot.adoc
+3
-0
README.adoc
spring-boot-samples/spring-boot-sample-cache/README.adoc
+11
-5
pom.xml
spring-boot-samples/spring-boot-sample-cache/pom.xml
+6
-9
CountryRepository.java
...-sample-cache/src/main/java/sample/CountryRepository.java
+4
-5
pom.xml
spring-boot-starters/pom.xml
+1
-0
pom.xml
spring-boot-starters/spring-boot-starter-cache/pom.xml
+34
-0
spring.provides
...starter-cache/src/main/resources/META-INF/spring.provides
+1
-0
No files found.
spring-boot-dependencies/pom.xml
View file @
fca192fa
...
...
@@ -230,6 +230,11 @@
<artifactId>
spring-boot-starter-batch
</artifactId>
<version>
1.3.0.BUILD-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-cache
</artifactId>
<version>
1.3.0.BUILD-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-cloud-connectors
</artifactId>
...
...
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
View file @
fca192fa
...
...
@@ -2331,6 +2331,9 @@ TIP: It is also possible to {spring-reference}/#cache-annotations-put[update] or
=== Supported cache providers
NOTE: To easily get started, just add `spring-boot-starter-cache` to the dependencies of
your application.
The cache abstraction does not provide an actual store and relies on a abstraction
materialized by the `org.springframework.cache.Cache` and
`org.springframework.cache.CacheManager` interfaces. Spring Boot auto-configures a
...
...
spring-boot-docs/src/main/asciidoc/using-spring-boot.adoc
View file @
fca192fa
...
...
@@ -267,6 +267,9 @@ The following application starters are provided by Spring Boot under the
|`spring-boot-starter-batch`
|Support for "`Spring Batch`" including HSQLDB database.
|`spring-boot-starter-cache`
|Support for Spring'
s
Cache
abstraction
.
|`
spring
-
boot
-
starter
-
cloud
-
connectors
`
|
Support
for
"`Spring Cloud Connectors`"
which
simplifies
connecting
to
services
in
cloud
platforms
like
Cloud
Foundry
and
Heroku
.
...
...
spring-boot-samples/spring-boot-sample-cache/README.adoc
View file @
fca192fa
...
...
@@ -16,6 +16,15 @@ the application starts a client invokes the service with a random code every 500
can look at the `/metrics` endpoint to review the cache statistics if your chosen
caching provider is supported.
== Using the JSR-107 annotations
The sample uses Spring's cache annotation. If you want to use the JSR-107 annotations
instead, simply add the `javax.cache:cache-api` dependency to the project. No further
configuration is necessary.
NOTE: You can use the JSR-107 annotations with _any_ cache provider; a JSR-107 compliant
cache provider is not necessary.
== Using a different cache provider
Initially, the project does not define any caching library so the abstraction works
...
...
@@ -45,11 +54,8 @@ can set the `spring.cache.infinispan.config` property to use the provided
=== JCache (JSR-107)
You do not need to use a JSR-107 compliant `CacheManager` to use the standard
annotations. As a matter of a fact, this sample uses by default the standard annotations
with a simple map-based `CacheManager` by default. If you want to configure your cache
infrastructure via the standard, you need a compliant implementation. You could try
the following:
If you want to configure your cache infrastructure via the standard, you need a compliant
implementation. You could try the following:
* `Hazelcast`: add `com.hazelcast:hazelcast`
* `Infinispan`: add `org.infinispan:infinispan-jcache`
...
...
spring-boot-samples/spring-boot-sample-cache/pom.xml
View file @
fca192fa
...
...
@@ -22,22 +22,19 @@
<dependencies>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-
web
</artifactId>
<artifactId>
spring-boot-starter-
cache
</artifactId>
</dependency>
<!-- Only used to expose cache metrics -->
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-actuator
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-context-support
</artifactId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
<dependency>
<groupId>
javax.cache
</groupId>
<artifactId>
cache-api
</artifactId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-actuator
</artifactId>
</dependency>
<!-- Additional cache providers
<dependency>
<groupId>net.sf.ehcache</groupId>
...
...
spring-boot-samples/spring-boot-sample-cache/src/main/java/sample/CountryRepository.java
View file @
fca192fa
...
...
@@ -16,16 +16,15 @@
package
sample
;
import
javax.cache.annotation.CacheDefaults
;
import
javax.cache.annotation.CacheResult
;
import
org.springframework.cache.annotation.CacheConfig
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.stereotype.Component
;
@Component
@Cache
Defaults
(
cacheName
=
"countries"
)
@Cache
Config
(
cacheNames
=
"countries"
)
public
class
CountryRepository
{
@Cache
Result
@Cache
able
public
Country
findByCode
(
String
code
)
{
System
.
out
.
println
(
"---> Loading country with code '"
+
code
+
"'"
);
return
new
Country
(
code
);
...
...
spring-boot-starters/pom.xml
View file @
fca192fa
...
...
@@ -24,6 +24,7 @@
<module>
spring-boot-starter-amqp
</module>
<module>
spring-boot-starter-aop
</module>
<module>
spring-boot-starter-batch
</module>
<module>
spring-boot-starter-cache
</module>
<module>
spring-boot-starter-cloud-connectors
</module>
<module>
spring-boot-starter-data-elasticsearch
</module>
<module>
spring-boot-starter-data-gemfire
</module>
...
...
spring-boot-starters/spring-boot-starter-cache/pom.xml
0 → 100644
View file @
fca192fa
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starters
</artifactId>
<version>
1.3.0.BUILD-SNAPSHOT
</version>
</parent>
<artifactId>
spring-boot-starter-cache
</artifactId>
<name>
Spring Boot Cache Starter
</name>
<description>
Spring Boot Cache Starter
</description>
<url>
http://projects.spring.io/spring-boot/
</url>
<organization>
<name>
Pivotal Software, Inc.
</name>
<url>
http://www.spring.io
</url>
</organization>
<properties>
<main.basedir>
${basedir}/../..
</main.basedir>
</properties>
<dependencies>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-context
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-context-support
</artifactId>
</dependency>
</dependencies>
</project>
spring-boot-starters/spring-boot-starter-cache/src/main/resources/META-INF/spring.provides
0 → 100644
View file @
fca192fa
provides: spring-context-support
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment