代码:
@Service
public class EmployeeService {
@Autowired
EmployeeMapper employeeMapper;
@Cacheable(cacheNames = {"emp"})
public Employee getEmp(Integer id){
System.out.println("查询"+id+"号员工");
return employeeMapper.getEmployee(id);
}
配置:
spring.datasource.url=jdbc:mysql://localhost:3306/spring_cache
spring.datasource.username=xxx
spring.datasource.password=xsg5207896
#spring.datasource.driver-class-name=com.mysql.jdbc.Driver
# 开启驼峰命名规则
mybatis.configuration.map-underscore-to-camel-case=true
logging.level.com.example.sbcache.mapper=debug
我看别人都是这么写的,为什么我的都不得行呢 求解 工具idea
https://blog.csdn.net/qq_15071263/article/details/84553102
参考一下这个文章,也许可以帮到你
https://blog.csdn.net/kimylrong/article/details/50126979
我 1.5.2 也不行的 自己搭建demo都可以不过是2.1.0的 怀疑是@cacheAble在低版本的springboot不支持