https://www.ehcache.org/documentation/3.10/xml.html
引入依赖
<!-- https://mvnrepository.com/artifact/org.ehcache/ehcache -->
<dependency>
<groupId>org.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>3.10.8</version>
</dependency>
第一种代码模式:
EHCacheTest.java
package com.imddy.jtest;
import org.ehcache.Cache;
import org.ehcache.CacheManager;
import org.ehcache.config.builders.CacheConfigurationBuilder;
import org.ehcache.config.builders.CacheManagerBuilder;
import org.ehcache.config.builders.ResourcePoolsBuilder;
public class EHCacheTest {
public static void main(String[] args) {
//获取到管理cache的CacheManager,
// 并且初识化了一个名为preConfigured的cache,
// 该cache里存储的entity的key类型为Long , value类型为String,
//该cache最多只能缓存100个entity
CacheManager cacheManager = CacheManagerBuilder.newCacheManagerBuilder()
.withCache("preConfigured", CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class,
ResourcePoolsBuilder.heap(100))
.build())
.build(true);
//通过CacheManager获取到名为preConfigured的cache
Cache<Long, String> preConfigured = cacheManager.getCache("preConfigured", Long.class, String.class);
//通过CacheManager根据特定配置再创建一个cache,名为myCache,该cache由cacheManager这个实例管理
Cache<Long, String> myCache = cacheManager.createCache("myCache",
CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class,
ResourcePoolsBuilder.heap(100))
.build());
//放入一个entity到myCache里,类似于Map的存储方式
myCache.put(1L, "da one!");
//从名为myCache的cache里获取key为1的value值
String value = myCache.get(1L);
//打印获取到的值
System.out.println(value);
//关闭CacheManager,这个方法会自动关闭该CacheManager管理的所有cache及service
cacheManager.close();
}
}
输出结果:
"C:\Program Files\Java\jdk1.8.0_202\bin\java.exe" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2022.3.2\lib\idea_rt.jar=53695:C:\Program Files\JetBrains\IntelliJ IDEA 2022.3.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_202\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\rt.jar;F:\otherporj\jtest\target\test-classes;F:\otherporj\jtest\target\classes;C:\Users\Administrator\.m2\repository\org\projectlombok\lombok\1.18.24\lombok-1.18.24.jar;C:\Users\Administrator\.m2\repository\org\springframework\boot\spring-boot-starter-test\2.6.14\spring-boot-starter-test-2.6.14.jar;C:\Users\Administrator\.m2\repository\org\springframework\boot\spring-boot-test\2.6.14\spring-boot-test-2.6.14.jar;C:\Users\Administrator\.m2\repository\org\springframework\boot\spring-boot-test-autoconfigure\2.6.14\spring-boot-test-autoconfigure-2.6.14.jar;C:\Users\Administrator\.m2\repository\com\jayway\jsonpath\json-path\2.6.0\json-path-2.6.0.jar;C:\Users\Administrator\.m2\repository\net\minidev\json-smart\2.4.8\json-smart-2.4.8.jar;C:\Users\Administrator\.m2\repository\net\minidev\accessors-smart\2.4.8\accessors-smart-2.4.8.jar;C:\Users\Administrator\.m2\repository\org\ow2\asm\asm\9.1\asm-9.1.jar;C:\Users\Administrator\.m2\repository\jakarta\xml\bind\jakarta.xml.bind-api\2.3.3\jakarta.xml.bind-api-2.3.3.jar;C:\Users\Administrator\.m2\repository\jakarta\activation\jakarta.activation-api\1.2.2\jakarta.activation-api-1.2.2.jar;C:\Users\Administrator\.m2\repository\org\assertj\assertj-core\3.21.0\assertj-core-3.21.0.jar;C:\Users\Administrator\.m2\repository\org\hamcrest\hamcrest\2.2\hamcrest-2.2.jar;C:\Users\Administrator\.m2\repository\org\junit\jupiter\junit-jupiter\5.8.2\junit-jupiter-5.8.2.jar;C:\Users\Administrator\.m2\repository\org\junit\jupiter\junit-jupiter-api\5.8.2\junit-jupiter-api-5.8.2.jar;C:\Users\Administrator\.m2\repository\org\opentest4j\opentest4j\1.2.0\opentest4j-1.2.0.jar;C:\Users\Administrator\.m2\repository\org\junit\platform\junit-platform-commons\1.8.2\junit-platform-commons-1.8.2.jar;C:\Users\Administrator\.m2\repository\org\apiguardian\apiguardian-api\1.1.2\apiguardian-api-1.1.2.jar;C:\Users\Administrator\.m2\repository\org\junit\jupiter\junit-jupiter-params\5.8.2\junit-jupiter-params-5.8.2.jar;C:\Users\Administrator\.m2\repository\org\junit\jupiter\junit-jupiter-engine\5.8.2\junit-jupiter-engine-5.8.2.jar;C:\Users\Administrator\.m2\repository\org\junit\platform\junit-platform-engine\1.8.2\junit-platform-engine-1.8.2.jar;C:\Users\Administrator\.m2\repository\org\mockito\mockito-core\4.0.0\mockito-core-4.0.0.jar;C:\Users\Administrator\.m2\repository\net\bytebuddy\byte-buddy\1.11.22\byte-buddy-1.11.22.jar;C:\Users\Administrator\.m2\repository\net\bytebuddy\byte-buddy-agent\1.11.22\byte-buddy-agent-1.11.22.jar;C:\Users\Administrator\.m2\repository\org\objenesis\objenesis\3.2\objenesis-3.2.jar;C:\Users\Administrator\.m2\repository\org\mockito\mockito-junit-jupiter\4.0.0\mockito-junit-jupiter-4.0.0.jar;C:\Users\Administrator\.m2\repository\org\skyscreamer\jsonassert\1.5.1\jsonassert-1.5.1.jar;C:\Users\Administrator\.m2\repository\com\vaadin\external\google\android-json\0.0.20131108.vaadin1\android-json-0.0.20131108.vaadin1.jar;C:\Users\Administrator\.m2\repository\org\springframework\spring-core\5.3.24\spring-core-5.3.24.jar;C:\Users\Administrator\.m2\repository\org\springframework\spring-jcl\5.3.24\spring-jcl-5.3.24.jar;C:\Users\Administrator\.m2\repository\org\springframework\spring-test\5.3.24\spring-test-5.3.24.jar;C:\Users\Administrator\.m2\repository\org\xmlunit\xmlunit-core\2.8.4\xmlunit-core-2.8.4.jar;C:\Users\Administrator\.m2\repository\org\springframework\boot\spring-boot-starter\2.6.14\spring-boot-starter-2.6.14.jar;C:\Users\Administrator\.m2\repository\org\springframework\boot\spring-boot\2.6.14\spring-boot-2.6.14.jar;C:\Users\Administrator\.m2\repository\org\springframework\spring-context\5.3.24\spring-context-5.3.24.jar;C:\Users\Administrator\.m2\repository\org\springframework\spring-aop\5.3.24\spring-aop-5.3.24.jar;C:\Users\Administrator\.m2\repository\org\springframework\spring-expression\5.3.24\spring-expression-5.3.24.jar;C:\Users\Administrator\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\2.6.14\spring-boot-autoconfigure-2.6.14.jar;C:\Users\Administrator\.m2\repository\org\springframework\boot\spring-boot-starter-logging\2.6.14\spring-boot-starter-logging-2.6.14.jar;C:\Users\Administrator\.m2\repository\ch\qos\logback\logback-classic\1.2.11\logback-classic-1.2.11.jar;C:\Users\Administrator\.m2\repository\ch\qos\logback\logback-core\1.2.11\logback-core-1.2.11.jar;C:\Users\Administrator\.m2\repository\org\apache\logging\log4j\log4j-to-slf4j\2.17.2\log4j-to-slf4j-2.17.2.jar;C:\Users\Administrator\.m2\repository\org\slf4j\jul-to-slf4j\1.7.36\jul-to-slf4j-1.7.36.jar;C:\Users\Administrator\.m2\repository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;C:\Users\Administrator\.m2\repository\org\yaml\snakeyaml\1.29\snakeyaml-1.29.jar;C:\Users\Administrator\.m2\repository\org\springframework\boot\spring-boot-starter-json\2.6.14\spring-boot-starter-json-2.6.14.jar;C:\Users\Administrator\.m2\repository\org\springframework\spring-web\5.3.24\spring-web-5.3.24.jar;C:\Users\Administrator\.m2\repository\org\springframework\spring-beans\5.3.24\spring-beans-5.3.24.jar;C:\Users\Administrator\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.13.4.2\jackson-databind-2.13.4.2.jar;C:\Users\Administrator\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.13.4\jackson-annotations-2.13.4.jar;C:\Users\Administrator\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.13.4\jackson-core-2.13.4.jar;C:\Users\Administrator\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.13.4\jackson-datatype-jdk8-2.13.4.jar;C:\Users\Administrator\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.13.4\jackson-datatype-jsr310-2.13.4.jar;C:\Users\Administrator\.m2\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.13.4\jackson-module-parameter-names-2.13.4.jar;C:\Users\Administrator\.m2\repository\org\springframework\boot\spring-boot-devtools\2.6.14\spring-boot-devtools-2.6.14.jar;C:\Users\Administrator\.m2\repository\com\google\guava\guava\31.1-jre\guava-31.1-jre.jar;C:\Users\Administrator\.m2\repository\com\google\guava\failureaccess\1.0.1\failureaccess-1.0.1.jar;C:\Users\Administrator\.m2\repository\com\google\guava\listenablefuture\9999.0-empty-to-avoid-conflict-with-guava\listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar;C:\Users\Administrator\.m2\repository\com\google\code\findbugs\jsr305\3.0.2\jsr305-3.0.2.jar;C:\Users\Administrator\.m2\repository\org\checkerframework\checker-qual\3.12.0\checker-qual-3.12.0.jar;C:\Users\Administrator\.m2\repository\com\google\errorprone\error_prone_annotations\2.11.0\error_prone_annotations-2.11.0.jar;C:\Users\Administrator\.m2\repository\com\google\j2objc\j2objc-annotations\1.3\j2objc-annotations-1.3.jar;C:\Users\Administrator\.m2\repository\org\apache\httpcomponents\httpclient\4.5.5\httpclient-4.5.5.jar;C:\Users\Administrator\.m2\repository\org\apache\httpcomponents\httpcore\4.4.15\httpcore-4.4.15.jar;C:\Users\Administrator\.m2\repository\com\alibaba\fastjson\1.2.83\fastjson-1.2.83.jar;C:\Users\Administrator\.m2\repository\org\apache\commons\commons-lang3\3.12.0\commons-lang3-3.12.0.jar;C:\Users\Administrator\.m2\repository\commons-codec\commons-codec\1.15\commons-codec-1.15.jar;C:\Users\Administrator\.m2\repository\cn\hutool\hutool-all\5.8.10\hutool-all-5.8.10.jar;C:\Users\Administrator\.m2\repository\org\apache\poi\poi-ooxml\5.2.3\poi-ooxml-5.2.3.jar;C:\Users\Administrator\.m2\repository\org\apache\poi\poi\5.2.3\poi-5.2.3.jar;C:\Users\Administrator\.m2\repository\org\apache\commons\commons-math3\3.6.1\commons-math3-3.6.1.jar;C:\Users\Administrator\.m2\repository\com\zaxxer\SparseBitSet\1.2\SparseBitSet-1.2.jar;C:\Users\Administrator\.m2\repository\org\apache\poi\poi-ooxml-lite\5.2.3\poi-ooxml-lite-5.2.3.jar;C:\Users\Administrator\.m2\repository\org\apache\xmlbeans\xmlbeans\5.1.1\xmlbeans-5.1.1.jar;C:\Users\Administrator\.m2\repository\xml-apis\xml-apis\1.4.01\xml-apis-1.4.01.jar;C:\Users\Administrator\.m2\repository\org\apache\commons\commons-compress\1.21\commons-compress-1.21.jar;C:\Users\Administrator\.m2\repository\commons-io\commons-io\2.11.0\commons-io-2.11.0.jar;C:\Users\Administrator\.m2\repository\com\github\virtuald\curvesapi\1.07\curvesapi-1.07.jar;C:\Users\Administrator\.m2\repository\org\apache\logging\log4j\log4j-api\2.17.2\log4j-api-2.17.2.jar;C:\Users\Administrator\.m2\repository\org\apache\commons\commons-collections4\4.4\commons-collections4-4.4.jar;C:\Users\Administrator\.m2\repository\org\ehcache\ehcache\3.10.8\ehcache-3.10.8.jar;C:\Users\Administrator\.m2\repository\javax\cache\cache-api\1.1.1\cache-api-1.1.1.jar;C:\Users\Administrator\.m2\repository\org\slf4j\slf4j-api\1.7.36\slf4j-api-1.7.36.jar;C:\Users\Administrator\.m2\repository\org\glassfish\jaxb\jaxb-runtime\2.3.7\jaxb-runtime-2.3.7.jar;C:\Users\Administrator\.m2\repository\org\glassfish\jaxb\txw2\2.3.7\txw2-2.3.7.jar;C:\Users\Administrator\.m2\repository\com\sun\istack\istack-commons-runtime\3.0.12\istack-commons-runtime-3.0.12.jar;C:\Users\Administrator\.m2\repository\com\sun\activation\jakarta.activation\1.2.2\jakarta.activation-1.2.2.jar" com.imddy.jtest.EHCacheTest
20:57:39.173 [main] DEBUG org.ehcache.core.spi.ServiceLocator - Starting 17 Services...
20:57:39.204 [main] DEBUG org.ehcache.core.internal.statistics.DefaultStatisticsService - Starting service
20:57:39.205 [main] DEBUG org.ehcache.core.spi.ServiceLocator - All Services successfully started, 17 Services in 33ms
20:57:39.206 [main] DEBUG org.ehcache.core.EhcacheManager - Creating Cache 'preConfigured' in EhcacheManager.
20:57:39.213 [main] DEBUG org.ehcache.impl.internal.spi.serialization.DefaultSerializationProvider - Serializer for <java.lang.Long> : org.ehcache.impl.serialization.LongSerializer@1e397ed7
20:57:39.215 [main] DEBUG org.ehcache.impl.internal.spi.serialization.DefaultSerializationProvider - Serializer for <java.lang.String> : org.ehcache.impl.serialization.StringSerializer@cb644e
20:57:39.234 [main] DEBUG org.ehcache.impl.internal.spi.copy.DefaultCopyProvider - Copier for <java.lang.Long> : org.ehcache.impl.copy.IdentityCopier@370736d9
20:57:39.234 [main] DEBUG org.ehcache.impl.internal.spi.copy.DefaultCopyProvider - Copier for <java.lang.String> : org.ehcache.impl.copy.IdentityCopier@5f9d02cb
20:57:39.274 [main] DEBUG org.ehcache.impl.internal.store.heap.OnHeapStore - No expiration strategy detected
20:57:39.364 [main] DEBUG org.ehcache.core.StatusTransitioner - {cache-alias=preConfigured}Initialize successful.
20:57:39.364 [main] INFO org.ehcache.core.EhcacheManager - Cache 'preConfigured' created in EhcacheManager.
20:57:39.364 [main] DEBUG org.ehcache.core.internal.statistics.DefaultStatisticsService - Moving from UNINITIALIZED to AVAILABLE
20:57:39.364 [main] DEBUG org.ehcache.core.internal.statistics.DefaultStatisticsService - Cache added preConfigured
20:57:39.383 [main] DEBUG org.ehcache.core.StatusTransitioner - Initialize successful.
20:57:39.384 [main] DEBUG org.ehcache.core.EhcacheManager - Creating Cache 'myCache' in EhcacheManager.
20:57:39.384 [main] DEBUG org.ehcache.impl.internal.spi.serialization.DefaultSerializationProvider - Serializer for <java.lang.Long> : org.ehcache.impl.serialization.LongSerializer@5e25a92e
20:57:39.385 [main] DEBUG org.ehcache.impl.internal.spi.serialization.DefaultSerializationProvider - Serializer for <java.lang.String> : org.ehcache.impl.serialization.StringSerializer@4df828d7
20:57:39.386 [main] DEBUG org.ehcache.impl.internal.spi.copy.DefaultCopyProvider - Copier for <java.lang.Long> : org.ehcache.impl.copy.IdentityCopier@b59d31
20:57:39.386 [main] DEBUG org.ehcache.impl.internal.spi.copy.DefaultCopyProvider - Copier for <java.lang.String> : org.ehcache.impl.copy.IdentityCopier@62fdb4a6
20:57:39.387 [main] DEBUG org.ehcache.impl.internal.store.heap.OnHeapStore - No expiration strategy detected
20:57:39.390 [main] DEBUG org.ehcache.core.StatusTransitioner - {cache-alias=myCache}Initialize successful.
20:57:39.391 [main] DEBUG org.ehcache.core.internal.statistics.DefaultStatisticsService - Cache added myCache
20:57:39.396 [main] INFO org.ehcache.core.EhcacheManager - Cache 'myCache' created in EhcacheManager.
da one!
20:57:39.406 [main] DEBUG org.ehcache.core.StatusTransitioner - {cache-alias=preConfigured}Close successful.
20:57:39.406 [main] INFO org.ehcache.core.EhcacheManager - Cache 'preConfigured' removed from EhcacheManager.
20:57:39.407 [main] DEBUG org.ehcache.core.StatusTransitioner - {cache-alias=myCache}Close successful.
20:57:39.407 [main] INFO org.ehcache.core.EhcacheManager - Cache 'myCache' removed from EhcacheManager.
20:57:39.407 [main] DEBUG org.ehcache.core.spi.ServiceLocator - Stopping 17 Services...
20:57:39.416 [main] DEBUG org.ehcache.core.internal.statistics.DefaultStatisticsService - Stopping service
20:57:39.416 [main] DEBUG org.ehcache.core.spi.ServiceLocator - All Services successfully stopped, 17 Services in 9ms
20:57:39.416 [main] DEBUG org.ehcache.core.StatusTransitioner - Close successful.
Process finished with exit code 0
第二种xml配置文件模式:
ehCache.xml
<?xml version="1.0" encoding="UTF-8"?>
<config
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns='http://www.ehcache.org/v3'
xsi:schemaLocation="http://www.ehcache.org/v3 http://www.ehcache.org/schema/ehcache-core.xsd">
<cache alias="foo">
<key-type>java.lang.String</key-type>
<value-type>java.lang.String</value-type>
<resources>
<heap unit="entries">2000</heap>
<offheap unit="MB">500</offheap>
</resources>
</cache>
<cache-template name="myDefaults">
<key-type>java.lang.Long</key-type>
<value-type>java.lang.String</value-type>
<heap unit="entries">200</heap>
</cache-template>
<cache alias="bar" uses-template="myDefaults">
<key-type>java.lang.Number</key-type>
</cache>
<cache alias="simpleCache" uses-template="myDefaults" />
</config>
EHCacheTest2.java
package com.imddy.jtest;
import org.ehcache.Cache;
import org.ehcache.CacheManager;
import org.ehcache.Status;
import org.ehcache.config.Configuration;
import org.ehcache.config.builders.CacheConfigurationBuilder;
import org.ehcache.config.builders.CacheManagerBuilder;
import org.ehcache.config.builders.ResourcePoolsBuilder;
import org.ehcache.xml.XmlConfiguration;
import java.net.URL;
public class EHCacheTest2 {
public static void main(String[] args) {
URL myUrl = EHCacheTest2.class.getResource("/ehCache.xml");
Configuration xmlConfig = new XmlConfiguration(myUrl);
CacheManager myCacheManager = CacheManagerBuilder.newCacheManager(xmlConfig);
myCacheManager.init(); //这个是重点,需要初始化
Status status = myCacheManager.getStatus();
System.out.println("status: " + status);
Cache<Long, String> simpleCache = myCacheManager.getCache("simpleCache", Long.class, String.class);
simpleCache.put(1L,"do it 1L !!!");
String value1 = simpleCache.get(1L);
System.out.println("1L: " + value1);
}
}
输出结果:
"C:\Program Files\Java\jdk1.8.0_202\bin\java.exe" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2022.3.2\lib\idea_rt.jar=52977:C:\Program Files\JetBrains\IntelliJ IDEA 2022.3.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_202\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\rt.jar;F:\otherporj\jtest\target\test-classes;F:\otherporj\jtest\target\classes;C:\Users\Administrator\.m2\repository\org\projectlombok\lombok\1.18.24\lombok-1.18.24.jar;C:\Users\Administrator\.m2\repository\org\springframework\boot\spring-boot-starter-test\2.6.14\spring-boot-starter-test-2.6.14.jar;C:\Users\Administrator\.m2\repository\org\springframework\boot\spring-boot-test\2.6.14\spring-boot-test-2.6.14.jar;C:\Users\Administrator\.m2\repository\org\springframework\boot\spring-boot-test-autoconfigure\2.6.14\spring-boot-test-autoconfigure-2.6.14.jar;C:\Users\Administrator\.m2\repository\com\jayway\jsonpath\json-path\2.6.0\json-path-2.6.0.jar;C:\Users\Administrator\.m2\repository\net\minidev\json-smart\2.4.8\json-smart-2.4.8.jar;C:\Users\Administrator\.m2\repository\net\minidev\accessors-smart\2.4.8\accessors-smart-2.4.8.jar;C:\Users\Administrator\.m2\repository\org\ow2\asm\asm\9.1\asm-9.1.jar;C:\Users\Administrator\.m2\repository\jakarta\xml\bind\jakarta.xml.bind-api\2.3.3\jakarta.xml.bind-api-2.3.3.jar;C:\Users\Administrator\.m2\repository\jakarta\activation\jakarta.activation-api\1.2.2\jakarta.activation-api-1.2.2.jar;C:\Users\Administrator\.m2\repository\org\assertj\assertj-core\3.21.0\assertj-core-3.21.0.jar;C:\Users\Administrator\.m2\repository\org\hamcrest\hamcrest\2.2\hamcrest-2.2.jar;C:\Users\Administrator\.m2\repository\org\junit\jupiter\junit-jupiter\5.8.2\junit-jupiter-5.8.2.jar;C:\Users\Administrator\.m2\repository\org\junit\jupiter\junit-jupiter-api\5.8.2\junit-jupiter-api-5.8.2.jar;C:\Users\Administrator\.m2\repository\org\opentest4j\opentest4j\1.2.0\opentest4j-1.2.0.jar;C:\Users\Administrator\.m2\repository\org\junit\platform\junit-platform-commons\1.8.2\junit-platform-commons-1.8.2.jar;C:\Users\Administrator\.m2\repository\org\apiguardian\apiguardian-api\1.1.2\apiguardian-api-1.1.2.jar;C:\Users\Administrator\.m2\repository\org\junit\jupiter\junit-jupiter-params\5.8.2\junit-jupiter-params-5.8.2.jar;C:\Users\Administrator\.m2\repository\org\junit\jupiter\junit-jupiter-engine\5.8.2\junit-jupiter-engine-5.8.2.jar;C:\Users\Administrator\.m2\repository\org\junit\platform\junit-platform-engine\1.8.2\junit-platform-engine-1.8.2.jar;C:\Users\Administrator\.m2\repository\org\mockito\mockito-core\4.0.0\mockito-core-4.0.0.jar;C:\Users\Administrator\.m2\repository\net\bytebuddy\byte-buddy\1.11.22\byte-buddy-1.11.22.jar;C:\Users\Administrator\.m2\repository\net\bytebuddy\byte-buddy-agent\1.11.22\byte-buddy-agent-1.11.22.jar;C:\Users\Administrator\.m2\repository\org\objenesis\objenesis\3.2\objenesis-3.2.jar;C:\Users\Administrator\.m2\repository\org\mockito\mockito-junit-jupiter\4.0.0\mockito-junit-jupiter-4.0.0.jar;C:\Users\Administrator\.m2\repository\org\skyscreamer\jsonassert\1.5.1\jsonassert-1.5.1.jar;C:\Users\Administrator\.m2\repository\com\vaadin\external\google\android-json\0.0.20131108.vaadin1\android-json-0.0.20131108.vaadin1.jar;C:\Users\Administrator\.m2\repository\org\springframework\spring-core\5.3.24\spring-core-5.3.24.jar;C:\Users\Administrator\.m2\repository\org\springframework\spring-jcl\5.3.24\spring-jcl-5.3.24.jar;C:\Users\Administrator\.m2\repository\org\springframework\spring-test\5.3.24\spring-test-5.3.24.jar;C:\Users\Administrator\.m2\repository\org\xmlunit\xmlunit-core\2.8.4\xmlunit-core-2.8.4.jar;C:\Users\Administrator\.m2\repository\org\springframework\boot\spring-boot-starter\2.6.14\spring-boot-starter-2.6.14.jar;C:\Users\Administrator\.m2\repository\org\springframework\boot\spring-boot\2.6.14\spring-boot-2.6.14.jar;C:\Users\Administrator\.m2\repository\org\springframework\spring-context\5.3.24\spring-context-5.3.24.jar;C:\Users\Administrator\.m2\repository\org\springframework\spring-aop\5.3.24\spring-aop-5.3.24.jar;C:\Users\Administrator\.m2\repository\org\springframework\spring-expression\5.3.24\spring-expression-5.3.24.jar;C:\Users\Administrator\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\2.6.14\spring-boot-autoconfigure-2.6.14.jar;C:\Users\Administrator\.m2\repository\org\springframework\boot\spring-boot-starter-logging\2.6.14\spring-boot-starter-logging-2.6.14.jar;C:\Users\Administrator\.m2\repository\ch\qos\logback\logback-classic\1.2.11\logback-classic-1.2.11.jar;C:\Users\Administrator\.m2\repository\ch\qos\logback\logback-core\1.2.11\logback-core-1.2.11.jar;C:\Users\Administrator\.m2\repository\org\apache\logging\log4j\log4j-to-slf4j\2.17.2\log4j-to-slf4j-2.17.2.jar;C:\Users\Administrator\.m2\repository\org\slf4j\jul-to-slf4j\1.7.36\jul-to-slf4j-1.7.36.jar;C:\Users\Administrator\.m2\repository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;C:\Users\Administrator\.m2\repository\org\yaml\snakeyaml\1.29\snakeyaml-1.29.jar;C:\Users\Administrator\.m2\repository\org\springframework\boot\spring-boot-starter-json\2.6.14\spring-boot-starter-json-2.6.14.jar;C:\Users\Administrator\.m2\repository\org\springframework\spring-web\5.3.24\spring-web-5.3.24.jar;C:\Users\Administrator\.m2\repository\org\springframework\spring-beans\5.3.24\spring-beans-5.3.24.jar;C:\Users\Administrator\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.13.4.2\jackson-databind-2.13.4.2.jar;C:\Users\Administrator\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.13.4\jackson-annotations-2.13.4.jar;C:\Users\Administrator\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.13.4\jackson-core-2.13.4.jar;C:\Users\Administrator\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.13.4\jackson-datatype-jdk8-2.13.4.jar;C:\Users\Administrator\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.13.4\jackson-datatype-jsr310-2.13.4.jar;C:\Users\Administrator\.m2\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.13.4\jackson-module-parameter-names-2.13.4.jar;C:\Users\Administrator\.m2\repository\org\springframework\boot\spring-boot-devtools\2.6.14\spring-boot-devtools-2.6.14.jar;C:\Users\Administrator\.m2\repository\com\google\guava\guava\31.1-jre\guava-31.1-jre.jar;C:\Users\Administrator\.m2\repository\com\google\guava\failureaccess\1.0.1\failureaccess-1.0.1.jar;C:\Users\Administrator\.m2\repository\com\google\guava\listenablefuture\9999.0-empty-to-avoid-conflict-with-guava\listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar;C:\Users\Administrator\.m2\repository\com\google\code\findbugs\jsr305\3.0.2\jsr305-3.0.2.jar;C:\Users\Administrator\.m2\repository\org\checkerframework\checker-qual\3.12.0\checker-qual-3.12.0.jar;C:\Users\Administrator\.m2\repository\com\google\errorprone\error_prone_annotations\2.11.0\error_prone_annotations-2.11.0.jar;C:\Users\Administrator\.m2\repository\com\google\j2objc\j2objc-annotations\1.3\j2objc-annotations-1.3.jar;C:\Users\Administrator\.m2\repository\org\apache\httpcomponents\httpclient\4.5.5\httpclient-4.5.5.jar;C:\Users\Administrator\.m2\repository\org\apache\httpcomponents\httpcore\4.4.15\httpcore-4.4.15.jar;C:\Users\Administrator\.m2\repository\com\alibaba\fastjson\1.2.83\fastjson-1.2.83.jar;C:\Users\Administrator\.m2\repository\org\apache\commons\commons-lang3\3.12.0\commons-lang3-3.12.0.jar;C:\Users\Administrator\.m2\repository\commons-codec\commons-codec\1.15\commons-codec-1.15.jar;C:\Users\Administrator\.m2\repository\cn\hutool\hutool-all\5.8.10\hutool-all-5.8.10.jar;C:\Users\Administrator\.m2\repository\org\apache\poi\poi-ooxml\5.2.3\poi-ooxml-5.2.3.jar;C:\Users\Administrator\.m2\repository\org\apache\poi\poi\5.2.3\poi-5.2.3.jar;C:\Users\Administrator\.m2\repository\org\apache\commons\commons-math3\3.6.1\commons-math3-3.6.1.jar;C:\Users\Administrator\.m2\repository\com\zaxxer\SparseBitSet\1.2\SparseBitSet-1.2.jar;C:\Users\Administrator\.m2\repository\org\apache\poi\poi-ooxml-lite\5.2.3\poi-ooxml-lite-5.2.3.jar;C:\Users\Administrator\.m2\repository\org\apache\xmlbeans\xmlbeans\5.1.1\xmlbeans-5.1.1.jar;C:\Users\Administrator\.m2\repository\xml-apis\xml-apis\1.4.01\xml-apis-1.4.01.jar;C:\Users\Administrator\.m2\repository\org\apache\commons\commons-compress\1.21\commons-compress-1.21.jar;C:\Users\Administrator\.m2\repository\commons-io\commons-io\2.11.0\commons-io-2.11.0.jar;C:\Users\Administrator\.m2\repository\com\github\virtuald\curvesapi\1.07\curvesapi-1.07.jar;C:\Users\Administrator\.m2\repository\org\apache\logging\log4j\log4j-api\2.17.2\log4j-api-2.17.2.jar;C:\Users\Administrator\.m2\repository\org\apache\commons\commons-collections4\4.4\commons-collections4-4.4.jar;C:\Users\Administrator\.m2\repository\org\ehcache\ehcache\3.10.8\ehcache-3.10.8.jar;C:\Users\Administrator\.m2\repository\javax\cache\cache-api\1.1.1\cache-api-1.1.1.jar;C:\Users\Administrator\.m2\repository\org\slf4j\slf4j-api\1.7.36\slf4j-api-1.7.36.jar;C:\Users\Administrator\.m2\repository\org\glassfish\jaxb\jaxb-runtime\2.3.7\jaxb-runtime-2.3.7.jar;C:\Users\Administrator\.m2\repository\org\glassfish\jaxb\txw2\2.3.7\txw2-2.3.7.jar;C:\Users\Administrator\.m2\repository\com\sun\istack\istack-commons-runtime\3.0.12\istack-commons-runtime-3.0.12.jar;C:\Users\Administrator\.m2\repository\com\sun\activation\jakarta.activation\1.2.2\jakarta.activation-1.2.2.jar" com.imddy.jtest.EHCacheTest2
20:43:25.392 [main] DEBUG org.ehcache.core.spi.ServiceLocator - Starting 17 Services...
20:43:25.405 [main] DEBUG org.ehcache.core.internal.statistics.DefaultStatisticsService - Starting service
20:43:25.406 [main] DEBUG org.ehcache.core.spi.ServiceLocator - All Services successfully started, 17 Services in 16ms
20:43:25.407 [main] DEBUG org.ehcache.core.EhcacheManager - Creating Cache 'bar' in EhcacheManager.
20:43:25.412 [main] DEBUG org.ehcache.impl.internal.spi.serialization.DefaultSerializationProvider - Serializer for <java.lang.Number> : org.ehcache.impl.serialization.CompactJavaSerializer@15de0b3c
20:43:25.413 [main] DEBUG org.ehcache.impl.internal.spi.serialization.DefaultSerializationProvider - Serializer for <java.lang.String> : org.ehcache.impl.serialization.StringSerializer@4b2bac3f
20:43:25.428 [main] DEBUG org.ehcache.impl.internal.spi.copy.DefaultCopyProvider - Copier for <java.lang.Number> : org.ehcache.impl.copy.IdentityCopier@7c9d8e2
20:43:25.428 [main] DEBUG org.ehcache.impl.internal.spi.copy.DefaultCopyProvider - Copier for <java.lang.String> : org.ehcache.impl.copy.IdentityCopier@20d525
20:43:25.456 [main] DEBUG org.ehcache.impl.internal.store.heap.OnHeapStore - No expiration strategy detected
20:43:25.535 [main] DEBUG org.ehcache.core.StatusTransitioner - {cache-alias=bar}Initialize successful.
20:43:25.535 [main] INFO org.ehcache.core.EhcacheManager - Cache 'bar' created in EhcacheManager.
20:43:25.535 [main] DEBUG org.ehcache.core.EhcacheManager - Creating Cache 'foo' in EhcacheManager.
20:43:25.536 [main] DEBUG org.ehcache.impl.internal.spi.serialization.DefaultSerializationProvider - Serializer for <java.lang.String> : org.ehcache.impl.serialization.StringSerializer@209da20d
20:43:25.536 [main] DEBUG org.ehcache.impl.internal.spi.serialization.DefaultSerializationProvider - Serializer for <java.lang.String> : org.ehcache.impl.serialization.StringSerializer@e15b7e8
20:43:25.538 [main] DEBUG org.ehcache.impl.internal.spi.copy.DefaultCopyProvider - Copier for <java.lang.String> : org.ehcache.impl.copy.IdentityCopier@342c38f8
20:43:25.538 [main] DEBUG org.ehcache.impl.internal.spi.copy.DefaultCopyProvider - Copier for <java.lang.String> : org.ehcache.impl.copy.IdentityCopier@c88a337
20:43:25.538 [main] DEBUG org.ehcache.impl.internal.store.heap.OnHeapStore - No expiration strategy detected
20:43:25.589 [main] INFO org.ehcache.shadow.org.terracotta.offheapstore.paging.UpfrontAllocatingPageSource - Allocating 500.0MB in chunks
20:43:25.696 [pool-1-thread-1] DEBUG org.ehcache.shadow.org.terracotta.offheapstore.paging.UpfrontAllocatingPageSource - 500.0MB chunk allocated
20:43:25.696 [main] DEBUG org.ehcache.shadow.org.terracotta.offheapstore.paging.UpfrontAllocatingPageSource - Took 106 ms to create off-heap storage of 500.0MB.
20:43:25.723 [main] DEBUG org.ehcache.shadow.org.terracotta.offheapstore.paging.UpfrontAllocatingPageSource - Allocating a 16KB buffer from chunk 0 &0
20:43:25.723 [main] DEBUG org.ehcache.shadow.org.terracotta.offheapstore.paging.UpfrontAllocatingPageSource - Allocating a 16KB buffer from chunk 0 &16384
20:43:25.723 [main] DEBUG org.ehcache.shadow.org.terracotta.offheapstore.paging.UpfrontAllocatingPageSource - Allocating a 16KB buffer from chunk 0 &32768
20:43:25.724 [main] DEBUG org.ehcache.shadow.org.terracotta.offheapstore.paging.UpfrontAllocatingPageSource - Allocating a 16KB buffer from chunk 0 &49152
20:43:25.724 [main] DEBUG org.ehcache.shadow.org.terracotta.offheapstore.paging.UpfrontAllocatingPageSource - Allocating a 16KB buffer from chunk 0 &65536
20:43:25.724 [main] DEBUG org.ehcache.shadow.org.terracotta.offheapstore.paging.UpfrontAllocatingPageSource - Allocating a 16KB buffer from chunk 0 &81920
20:43:25.724 [main] DEBUG org.ehcache.shadow.org.terracotta.offheapstore.paging.UpfrontAllocatingPageSource - Allocating a 16KB buffer from chunk 0 &98304
20:43:25.724 [main] DEBUG org.ehcache.shadow.org.terracotta.offheapstore.paging.UpfrontAllocatingPageSource - Allocating a 16KB buffer from chunk 0 &114688
20:43:25.724 [main] DEBUG org.ehcache.shadow.org.terracotta.offheapstore.paging.UpfrontAllocatingPageSource - Allocating a 16KB buffer from chunk 0 &131072
20:43:25.724 [main] DEBUG org.ehcache.shadow.org.terracotta.offheapstore.paging.UpfrontAllocatingPageSource - Allocating a 16KB buffer from chunk 0 &147456
20:43:25.724 [main] DEBUG org.ehcache.shadow.org.terracotta.offheapstore.paging.UpfrontAllocatingPageSource - Allocating a 16KB buffer from chunk 0 &163840
20:43:25.724 [main] DEBUG org.ehcache.shadow.org.terracotta.offheapstore.paging.UpfrontAllocatingPageSource - Allocating a 16KB buffer from chunk 0 &180224
20:43:25.725 [main] DEBUG org.ehcache.shadow.org.terracotta.offheapstore.paging.UpfrontAllocatingPageSource - Allocating a 16KB buffer from chunk 0 &196608
20:43:25.725 [main] DEBUG org.ehcache.shadow.org.terracotta.offheapstore.paging.UpfrontAllocatingPageSource - Allocating a 16KB buffer from chunk 0 &212992
20:43:25.725 [main] DEBUG org.ehcache.shadow.org.terracotta.offheapstore.paging.UpfrontAllocatingPageSource - Allocating a 16KB buffer from chunk 0 &229376
20:43:25.725 [main] DEBUG org.ehcache.shadow.org.terracotta.offheapstore.paging.UpfrontAllocatingPageSource - Allocating a 16KB buffer from chunk 0 &245760
20:43:25.725 [main] DEBUG org.ehcache.core.StatusTransitioner - {cache-alias=foo}Initialize successful.
20:43:25.725 [main] INFO org.ehcache.core.EhcacheManager - Cache 'foo' created in EhcacheManager.
20:43:25.725 [main] DEBUG org.ehcache.core.EhcacheManager - Creating Cache 'simpleCache' in EhcacheManager.
20:43:25.725 [main] DEBUG org.ehcache.impl.internal.spi.serialization.DefaultSerializationProvider - Serializer for <java.lang.Long> : org.ehcache.impl.serialization.LongSerializer@536f2a7e
20:43:25.725 [main] DEBUG org.ehcache.impl.internal.spi.serialization.DefaultSerializationProvider - Serializer for <java.lang.String> : org.ehcache.impl.serialization.StringSerializer@72bc6553
20:43:25.725 [main] DEBUG org.ehcache.impl.internal.spi.copy.DefaultCopyProvider - Copier for <java.lang.Long> : org.ehcache.impl.copy.IdentityCopier@66982506
20:43:25.726 [main] DEBUG org.ehcache.impl.internal.spi.copy.DefaultCopyProvider - Copier for <java.lang.String> : org.ehcache.impl.copy.IdentityCopier@70cf32e3
20:43:25.726 [main] DEBUG org.ehcache.impl.internal.store.heap.OnHeapStore - No expiration strategy detected
20:43:25.727 [main] DEBUG org.ehcache.core.StatusTransitioner - {cache-alias=simpleCache}Initialize successful.
20:43:25.727 [main] INFO org.ehcache.core.EhcacheManager - Cache 'simpleCache' created in EhcacheManager.
20:43:25.728 [main] DEBUG org.ehcache.core.internal.statistics.DefaultStatisticsService - Moving from UNINITIALIZED to AVAILABLE
20:43:25.728 [main] DEBUG org.ehcache.core.internal.statistics.DefaultStatisticsService - Cache added bar
20:43:25.738 [main] DEBUG org.ehcache.core.internal.statistics.DefaultStatisticsService - Cache added foo
20:43:25.745 [main] DEBUG org.ehcache.core.internal.statistics.DefaultStatisticsService - Cache added simpleCache
20:43:25.747 [main] DEBUG org.ehcache.core.StatusTransitioner - Initialize successful.
status: AVAILABLE
1L: do it 1L !!!
Process finished with exit code 0
标签:EHCache,Administrator,Users,repository,3.10,jar,初识,m2,org
From: https://blog.51cto.com/lenglingx/9445281