service层使用ehcache
This commit is contained in:
parent
34233e79de
commit
4314a35518
|
@ -30,6 +30,13 @@
|
||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- servlet -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.servlet</groupId>
|
||||||
|
<artifactId>servlet-api</artifactId>
|
||||||
|
<version>2.5</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<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">
|
<!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">
|
<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">
|
<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.mapper.UserVOMapper;
|
||||||
import com.zheng.cms.dao.model.UserVO;
|
import com.zheng.cms.dao.model.UserVO;
|
||||||
import com.zheng.cms.service.UserService;
|
import com.zheng.cms.service.UserService;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户service实现
|
* 用户service实现
|
||||||
* @author shuzheng
|
* @author shuzheng
|
||||||
|
@ -17,6 +22,8 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
@Transactional
|
@Transactional
|
||||||
public class UserServiceImpl implements UserService {
|
public class UserServiceImpl implements UserService {
|
||||||
|
|
||||||
|
private static Logger _log = LoggerFactory.getLogger(UserServiceImpl.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserMapper userMapper;
|
private UserMapper userMapper;
|
||||||
|
|
||||||
|
@ -38,6 +45,7 @@ public class UserServiceImpl implements UserService {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Cacheable(value="ehcache")
|
||||||
public UserVO selectUserWithBook(int id) {
|
public UserVO selectUserWithBook(int id) {
|
||||||
return userVOMapper.selectUserWithBook(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.User;
|
||||||
import com.zheng.cms.dao.model.UserVO;
|
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.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
Loading…
Reference in New Issue