Mybatis二级缓存 使用@CacheNamespace 失效

Mybatis二级缓存,配置文件和接口注释是不能够配合使用的。只能通过全注解的方式才能够生效;

例如:

@CacheNamespace(implementation = MybatisRedisCache.class)
public interface TestMapper(
    @Select("select t_user.* from t_user where t_user.t_user_id = #{tUserId}")
    @Options(useCache = true)
    List<PeoplePo> getUser(PeopleVo p);
}

或者全部通过xml配置文件的方式使用,例如:

<?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.example.TestMapper">

    <cache type="com.example.MybatisRedisCache">
        <property name="eviction" value="LRU" />
        <property name="flushInterval" value="6000000" />
        <property name="size" value="1024" />
        <property name="readOnly" value="false" />
    </cache>

    <select id="selectById">
        select * from test where id = #{id}
    </select >
</mapper>