我正在分析simple Spring Boot 1.5 Spring Data REST application。令我惊讶的是,根据Atteo Evo Inflector,JProfiler是超过一半CPU的巨大热点:
您应该能够使用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应用程序以避免运行时变形开销?