久视伤血,久卧伤气,久坐伤肉,久立伤骨,久行伤筋。——曹廷栋

代码如下

1
2
3
4
5
6
7
8
9
10
11
12
13
import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.cache.impl.PerpetualCache;

@Mapper
@CacheNamespace(implementation = PerpetualCache.class, blocking = false)
public interface MyMapper {

@Select("SELECT * FROM my_table WHERE id = #{id}")
MyEntity selectById(int id);

}

上使用@CacheNamespace注解,并将implementation设置为org.apache.ibatis.cache.impl.PerpetualCache.classblocking设置为false即可禁用二级缓存