Improve caching configuration

Rather than creating a `CacheManager` ourselves, we now rely on JCache
to provide a `CacheManager` that we'll augment with the caches that
initializr needs.

If Initializr is embedded in another app and that app uses JCache, then
its cache manager will be transparently upgraded to define the caches
that initializr needs. If not, such caches will have to be created as
part of the custom config.

Also, caching only kicks in if required at the service level.

This commit also switches the cache implementation to EhCache 3.

See gh-389
This commit is contained in:
Stephane Nicoll
2017-03-29 12:55:29 +02:00
parent 8ac7369138
commit 9a83defc4c
4 changed files with 47 additions and 36 deletions

View File

@@ -26,6 +26,15 @@
<artifactId>initializr-actuator</artifactId>
</dependency>
<dependency>
<groupId>javax.cache</groupId>
<artifactId>cache-api</artifactId>
</dependency>
<dependency>
<groupId>org.ehcache</groupId>
<artifactId>ehcache</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>

View File

@@ -23,6 +23,7 @@ import io.spring.initializr.web.project.LegacyStsController;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurerSupport;
@@ -37,6 +38,7 @@ import org.springframework.web.servlet.resource.ResourceUrlProvider;
* @author Stephane Nicoll
*/
@SpringBootApplication
@EnableCaching
public class InitializrService {
public static void main(String[] args) {