public interface MyRespository extends CrudRepository<MyEntity, Long> {
@CachePut(value = "mycache", key = "id")
@Override
public <S extends MyEntity> S save(S entity);
}
@Entity
public class MyEntity {
@Id
private Long id;
public Long getId() { return id; }
public void setId(Long id) { this.id = id; }
}
结果:
org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 0): 在“org.springframework.cache.interceptor.CacheExpressionRootObject”类型的对象上找不到属性或字段“id” - 也许不公开?