- Конфигурация XML
java.lang.Object
java.lang.Object
360
1000 - Основная программа
package org.ehcache;
import org.ehcache.config.Configuration;
import org.ehcache.config.builders.CacheManagerBuilder;
import org.ehcache.xml.XmlConfiguration;
import java.net.MalformedURLException;
public class AuthEhCache {
public static void main(String[] args) throws MalformedURLException {
Configuration xmlConfig = new XmlConfiguration(AuthEhCache.class.getResource("/authEhcache.xml"));
// Create a simple cache configuration
CacheManager cacheManager = CacheManagerBuilder.newCacheManager(xmlConfig);
cacheManager.init();
Cache ehCache = cacheManager.getCache("authprovidercache", Object.class, Object.class);
ehCache.put("a", "b");
System.out.println(ehCache.get("a"));
}
}
Трассировка стека ошибок:
Exception in thread "main" java.lang.IllegalStateException: No factories exist for interface org.ehcache.jsr107.Jsr107Service
at org.ehcache.core.spi.ServiceLocator$DependencySet.with(ServiceLocator.java:271)
at org.ehcache.core.EhcacheManager.resolveServices(EhcacheManager.java:152)
at org.ehcache.core.EhcacheManager.(EhcacheManager.java:125)
at org.ehcache.core.EhcacheManager.(EhcacheManager.java:115)
at org.ehcache.core.EhcacheManager.(EhcacheManager.java:107)
at org.ehcache.config.builders.CacheManagerBuilder.newCacheManager(CacheManagerBuilder.java:108)
at org.ehcache.AuthEhCache.main(AuthEhCache.java:15)
Подробнее здесь: https://stackoverflow.com/questions/786 ... che-3-10-8