平时注解用得多,突然翻到自己以前写的代码,希望以后能用上吧
package test.spring; import net.sf.ehcache.Cache; import net.sf.ehcache.CacheManager; import net.sf.ehcache.Element; public class TestMap { public static void main(String[] args) { CacheManager manager = CacheManager.create("src/config/ehcache.xml"); manager.addCache("testCache"); Cache test = manager.getCache("testCache"); test.put(new Element("key1", "value1")); manager.shutdown(); // String path = TestMap.class.getResource("/").getPath(); // System.out.println(path); // String relativelyPath=System.getProperty("user.dir"); // relativelyPath += "/WebContent/WEB-INF/layout/default.xml"; // System.out.println(relativelyPath); // // File file = new File(relativelyPath); // System.out.println(file.exists()); } }