使用以下@NodeEntity
@NodeEntity
public class Person extends BasePersistenceObject {
@GraphId
Long id;
String fullName;
@Indexed(unique=true)
String email;
String passwordHash = null;
@JsonIgnore
public String getPasswordHash() {
return passwordHash;
}
...
}
我仍然可以通过以下控制器方法在JSON响应中看到passwordHash:
@RequestMapping(value = "/login", method=RequestMethod.POST)
public @ResponseBody Person login(@RequestBody Map<String, String> credentials, HttpServletRequest request) throws AuthorizationException {
String email = credentials.get("email");
String password = credentials.get("password");
String ipAddress = request.getRemoteAddr();
return authService.authenticate(email, password, ipAddress);
}
答案 0 :(得分:0)
Spring Data Neo4J与JSON序列化无关,这是Spring MVC和Jackson或Gson的责任,具体取决于您使用的内容。因此,请确保Jackson用于JSON序列化,否则注释将无效。