If you use the service, you’ll notice that the logs have lots of entries with the message
Fetching boot metadata from spring.io/project_metadata/spring-boot
. To avoid
checking for the latest Spring Boot versions too often, you should enable caching on your
service. Spring Initializr has some auto-configuration to apply the proper caches if you
are willing to use a JCache (JSR-107) implementation.
Add the javax.cache:cache-api
and your favorite JCache implementation and simply enable
caching by adding @EnableCaching
to your @SpringBootApplication
. For instance, you
could use ehcache
by adding the following:
<dependency> <groupId>javax.cache</groupId> <artifactId>cache-api</artifactId> </dependency> <dependency> <groupId>org.ehcache</groupId> <artifactId>ehcache</artifactId> </dependency>
Or if you are using Gradle:
compile("javax.cache:cache-api") compile("org.ehcache:ehcache")
You’ll notice that the log entry is much more rare. If you do not want to use JSR-107, you should configure the cache yourselves. Here are the caches used by the application (each one will require some configuration to get it working):
Table 9.1. Cache configuration
cache name | Description |
---|---|
| Cache the full metadata of the service. When the metadata expires, it is fully resolved again (including a check on spring.io for the latest Spring Boot versions). Adapt the expiration settings accordingly. |
| Cache dependency-specific metadata. |
| Cache resources that are used to generate projects. |