我正在使用当前版本的Spring Data Rest和Spring Data JPA并具有以下实体:
public class User {
@Id
@GeneratedValue
private Long id;
private String name;
private String password;
private String email;
...getter/setter methods...
}
Run Code Online (Sandbox Code Playgroud)
我也在用Spring Security.
我的用户存储库:
@RepositoryRestResource(
collectionResourceRel = "user",
path = "user",
excerptProjection = UserSimpleProjection.class)
public interface UserRepository extends PagingAndSortingRepository<User, Long> {
}
Run Code Online (Sandbox Code Playgroud)
例如:
http://localhost:8080/user/1- 所有字段都可见http://localhost:8080/user/2-只是id和name可见.我和杰克逊尝试了不同的解决方案,没有一个能解决我的问题:
然后我找到了预测. …