service层使用ehcache
This commit is contained in:
parent
34233e79de
commit
4314a35518
|
@ -30,6 +30,13 @@
|
|||
<version>1.0.0</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<!-- servlet -->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zheng.cms.dao.mapper.UserVOMapper">
|
||||
|
||||
<!-- 缓存 -->
|
||||
<!--<cache type="PERPETUAL" eviction="LRU" flushInterval="60000" size="1024" readOnly="true"/>-->
|
||||
<cache type="org.mybatis.caches.ehcache.LoggingEhcache" />
|
||||
|
||||
<!-- 结果映射关系 -->
|
||||
<resultMap id="UserResultMap" type="userVO">
|
||||
|
|
|
@ -4,10 +4,15 @@ import com.zheng.cms.dao.mapper.UserMapper;
|
|||
import com.zheng.cms.dao.mapper.UserVOMapper;
|
||||
import com.zheng.cms.dao.model.UserVO;
|
||||
import com.zheng.cms.service.UserService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* 用户service实现
|
||||
* @author shuzheng
|
||||
|
@ -17,6 +22,8 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
@Transactional
|
||||
public class UserServiceImpl implements UserService {
|
||||
|
||||
private static Logger _log = LoggerFactory.getLogger(UserServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private UserMapper userMapper;
|
||||
|
||||
|
@ -38,6 +45,7 @@ public class UserServiceImpl implements UserService {
|
|||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Cacheable(value="ehcache")
|
||||
public UserVO selectUserWithBook(int id) {
|
||||
return userVOMapper.selectUserWithBook(id);
|
||||
}
|
||||
|
|
|
@ -2,9 +2,6 @@ package com.zheng.cms.service;
|
|||
|
||||
import com.zheng.cms.dao.model.User;
|
||||
import com.zheng.cms.dao.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;
|
||||
|
@ -27,7 +24,7 @@ public class UserServiceTest {
|
|||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
|
||||
@Test
|
||||
public void index() {
|
||||
// 自定义接口调用
|
||||
|
|
Loading…
Reference in New Issue