平时注解用得多,突然翻到自己以前写的代码,希望以后能用上吧

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());
    }
}

 

相关文章:

  • 2021-10-12
  • 2022-02-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-07
猜你喜欢
  • 2021-10-16
  • 2021-11-03
  • 2022-12-23
  • 2021-06-03
  • 2021-09-21
  • 2022-12-23
  • 2021-12-06
相关资源
相似解决方案