在Spring Data REST中静态配置rel

时间:2017-05-11 16:30:30

标签: java spring-data-rest spring-hateoas

我正在分析simple Spring Boot 1.5 Spring Data REST application。令我惊讶的是,根据Atteo Evo InflectorJProfiler是超过一半CPU的巨大热点:

enter image description here

您应该能够使用Apache Bench

重现这一点
ab2 -c 1 -n 10000 http://localhost:8080/people

存储库是:

@RepositoryRestResource(collectionResourceRel = "people", path = "people")
public interface PersonRepository 
    extends PagingAndSortingRepository<Person, Long> {
    List<Person> findByLastName(@Param("name") String name);
}

和(Lombok - ed)数据:

@Data
@NoArgsConstructor
@Entity
public class Person {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private long id;

    private String firstName;
    private String lastName;

    @JsonSerialize(using = MyLocalDateSerializer.class)
    private LocalDate birthDate;

    public Person(String firstName, String lastName, String birthDate) {
        this.firstName = firstName;
        this.lastName = lastName;
        this.birthDate = LocalDate.parse(birthDate);
    }
}

当存储库静态定义@RepositoryRestResource时,为什么Spring HATEOAS尝试使用collectionResourceRel存储库?任何想法是什么正确的注释配置我的Spring Data REST应用程序以避免运行时变形开销?

0 个答案:

没有答案