diff --git a/cms/cms-dao/src/main/resources/applicationContext-jdbc.xml b/cms/cms-dao/src/main/resources/applicationContext-jdbc.xml index f9ea1090..6a4574c9 100644 --- a/cms/cms-dao/src/main/resources/applicationContext-jdbc.xml +++ b/cms/cms-dao/src/main/resources/applicationContext-jdbc.xml @@ -61,5 +61,5 @@ - + \ No newline at end of file diff --git a/cms/cms-service/src/test/java/com/zheng/cms/service/UserServiceTest.java b/cms/cms-service/src/test/java/com/zheng/cms/service/UserServiceTest.java index 543dd227..ee74e5d8 100644 --- a/cms/cms-service/src/test/java/com/zheng/cms/service/UserServiceTest.java +++ b/cms/cms-service/src/test/java/com/zheng/cms/service/UserServiceTest.java @@ -2,6 +2,9 @@ package com.zheng.cms.service; import com.zheng.cms.model.User; import com.zheng.cms.model.UserVO; +import net.sf.ehcache.Cache; +import net.sf.ehcache.CacheManager; +import net.sf.ehcache.Element; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -17,7 +20,8 @@ import org.springframework.test.context.transaction.TransactionConfiguration; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration({ "classpath:applicationContext.xml", - "classpath:applicationContext-jdbc.xml" + "classpath:applicationContext-jdbc.xml", + "classpath:applicationContext-ehcache.xml" }) @TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true) public class UserServiceTest { @@ -33,6 +37,27 @@ public class UserServiceTest { // 自动生成接口调用 User user = userService.getMapper().selectByPrimaryKey(1); System.out.println(null == user ? "null" :user.getNickname()); + + // Create a cache manager + final CacheManager cacheManager = CacheManager.getInstance(); + + // create the cache called "hello-world" + final Cache cache = cacheManager.getCache("ehCache"); + + // create a key to map the data to + final String key = "key"; + + // Create a data element + final Element element = new Element(key, "value"); + + // Put the element into the data store + cache.put(element); + + // Retrieve the data element + final Element cacheElement = cache.get(key); + + // Print the value + System.out.println(cacheElement.getObjectValue()); } } diff --git a/cms/cms-web/src/main/webapp/WEB-INF/web.xml b/cms/cms-web/src/main/webapp/WEB-INF/web.xml index a5c07cda..5c2b7322 100644 --- a/cms/cms-web/src/main/webapp/WEB-INF/web.xml +++ b/cms/cms-web/src/main/webapp/WEB-INF/web.xml @@ -28,7 +28,8 @@ contextConfigLocation classpath:applicationContext.xml, - classpath:applicationContext-jdbc.xml + classpath:applicationContext-jdbc.xml, + classpath:applicationContext-ehcache.xml diff --git a/common/pom.xml b/common/pom.xml index 4748647f..903218cb 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -27,7 +27,7 @@ org.springframework - spring-context + spring-context-support ${spring.version} @@ -61,15 +61,11 @@ pagehelper 4.1.6 + - org.mybatis - mybatis-ehcache - 1.0.0 - - - org.ehcache + net.sf.ehcache ehcache - 3.1.3 + 2.10.0 diff --git a/common/src/main/resources/applicationContext-ehcache.xml b/common/src/main/resources/applicationContext-ehcache.xml new file mode 100644 index 00000000..e2e24962 --- /dev/null +++ b/common/src/main/resources/applicationContext-ehcache.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/resources/applicationContext.xml b/common/src/main/resources/applicationContext.xml index 98a4e401..b4066747 100644 --- a/common/src/main/resources/applicationContext.xml +++ b/common/src/main/resources/applicationContext.xml @@ -1,18 +1,12 @@ + http://www.springframework.org/schema/context/spring-context.xsd"> diff --git a/common/src/main/resources/ehcache.xml b/common/src/main/resources/ehcache.xml new file mode 100644 index 00000000..f472c4f8 --- /dev/null +++ b/common/src/main/resources/ehcache.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + \ No newline at end of file