2
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” - 也许不公开?

4

1 回答 1

1

通过索引访问对象key = "#a0.id"工作,但我仍然不知道为什么不能通过它的名称访问对象。

于 2016-06-02T08:22:42.993 回答