mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-15 01:07:30 +08:00
Restore Ehcache 3 Support
See gh-30002
This commit is contained in:
parent
1bf6e08d1b
commit
3ed3d3eb36
@ -88,6 +88,11 @@ dependencies {
|
||||
optional("org.eclipse.jetty.websocket:websocket-jetty-server") {
|
||||
exclude(group: "org.eclipse.jetty", module: "jetty-jndi")
|
||||
}
|
||||
optional("org.ehcache:ehcache") {
|
||||
artifact {
|
||||
classifier = 'jakarta'
|
||||
}
|
||||
}
|
||||
optional("org.elasticsearch.client:elasticsearch-rest-client") {
|
||||
exclude group: "commons-logging", module: "commons-logging"
|
||||
}
|
||||
|
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.cache;
|
||||
|
||||
import org.ehcache.jsr107.EhcacheCachingProvider;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.cache.CacheAutoConfigurationTests.DefaultCacheConfiguration;
|
||||
import org.springframework.boot.testsupport.classpath.ClassPathExclusions;
|
||||
import org.springframework.cache.jcache.JCacheCacheManager;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link CacheAutoConfiguration} with EhCache 3.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
@ClassPathExclusions("ehcache-2*.jar")
|
||||
class EhCache3CacheAutoConfigurationTests extends AbstractCacheAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
void ehcache3AsJCacheWithCaches() {
|
||||
String cachingProviderFqn = EhcacheCachingProvider.class.getName();
|
||||
this.contextRunner.withUserConfiguration(DefaultCacheConfiguration.class)
|
||||
.withPropertyValues("spring.cache.type=jcache", "spring.cache.jcache.provider=" + cachingProviderFqn,
|
||||
"spring.cache.cacheNames[0]=foo", "spring.cache.cacheNames[1]=bar")
|
||||
.run((context) -> {
|
||||
JCacheCacheManager cacheManager = getCacheManager(context, JCacheCacheManager.class);
|
||||
assertThat(cacheManager.getCacheNames()).containsOnly("foo", "bar");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void ehcache3AsJCacheWithConfig() {
|
||||
String cachingProviderFqn = EhcacheCachingProvider.class.getName();
|
||||
String configLocation = "ehcache3.xml";
|
||||
this.contextRunner.withUserConfiguration(DefaultCacheConfiguration.class)
|
||||
.withPropertyValues("spring.cache.type=jcache", "spring.cache.jcache.provider=" + cachingProviderFqn,
|
||||
"spring.cache.jcache.config=" + configLocation)
|
||||
.run((context) -> {
|
||||
JCacheCacheManager cacheManager = getCacheManager(context, JCacheCacheManager.class);
|
||||
|
||||
Resource configResource = new ClassPathResource(configLocation);
|
||||
assertThat(cacheManager.getCacheManager().getURI()).isEqualTo(configResource.getURI());
|
||||
assertThat(cacheManager.getCacheNames()).containsOnly("foo", "bar");
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -3,8 +3,8 @@
|
||||
xmlns='http://www.ehcache.org/v3'
|
||||
xmlns:jsr107='http://www.ehcache.org/v3/jsr107'
|
||||
xsi:schemaLocation="
|
||||
http://www.ehcache.org/v3 https://www.ehcache.org/schema/ehcache-core-3.1.xsd
|
||||
http://www.ehcache.org/v3/jsr107 https://www.ehcache.org/schema/ehcache-107-ext-3.1.xsd">
|
||||
http://www.ehcache.org/v3 https://www.ehcache.org/schema/ehcache-core-3.10.xsd
|
||||
http://www.ehcache.org/v3/jsr107 https://www.ehcache.org/schema/ehcache-107-ext-3.10.xsd">
|
||||
|
||||
<cache-template name="example">
|
||||
<heap unit="entries">200</heap>
|
||||
|
@ -191,6 +191,19 @@ bom {
|
||||
]
|
||||
}
|
||||
}
|
||||
library("Ehcache3", "3.10.0") {
|
||||
group("org.ehcache") {
|
||||
modules = [
|
||||
"ehcache" {
|
||||
classifier = 'jakarta'
|
||||
},
|
||||
"ehcache-clustered",
|
||||
"ehcache-transactions" {
|
||||
classifier = 'jakarta'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
library("Elasticsearch", "7.17.1") {
|
||||
group("org.elasticsearch") {
|
||||
modules = [
|
||||
|
@ -2,7 +2,7 @@
|
||||
== IO
|
||||
If your application needs IO capabilities, see one or more of the following sections:
|
||||
|
||||
* *Caching:* <<io#io.caching, Caching support with Hazelcast and more>>
|
||||
* *Caching:* <<io#io.caching, Caching support with EhCache, Hazelcast and more>>
|
||||
* *Quartz:* <<io#io.quartz, Quartz Scheduling>>
|
||||
* *Mail:* <<io#io.email, Sending Email>>
|
||||
* *Validation:* <<io#io.validation, JSR-303 Validation>>
|
||||
|
@ -37,7 +37,7 @@ The cache abstraction does not provide an actual store and relies on abstraction
|
||||
If you have not defined a bean of type `CacheManager` or a `CacheResolver` named `cacheResolver` (see {spring-framework-api}/cache/annotation/CachingConfigurer.html[`CachingConfigurer`]), Spring Boot tries to detect the following providers (in the indicated order):
|
||||
|
||||
. <<io#io.caching.provider.generic,Generic>>
|
||||
. <<io#io.caching.provider.jcache,JCache (JSR-107)>> (Hazelcast and others)
|
||||
. <<io#io.caching.provider.jcache,JCache (JSR-107)>> (EhCache 3, Hazelcast, and others)
|
||||
. <<io#io.caching.provider.hazelcast,Hazelcast>>
|
||||
. <<io#io.caching.provider.couchbase,Couchbase>>
|
||||
. <<io#io.caching.provider.redis,Redis>>
|
||||
|
@ -12,6 +12,14 @@ def caches = [
|
||||
"couchbase": [
|
||||
project(":spring-boot-project:spring-boot-starters:spring-boot-starter-data-couchbase")
|
||||
],
|
||||
"ehcache": [
|
||||
"javax.cache:cache-api",
|
||||
dependencies.create("org.ehcache:ehcache") {
|
||||
artifact {
|
||||
classifier = 'jakarta'
|
||||
}
|
||||
}
|
||||
],
|
||||
"hazelcast": [
|
||||
"com.hazelcast:hazelcast",
|
||||
"com.hazelcast:hazelcast-spring"
|
||||
|
Loading…
Reference in New Issue
Block a user