我正在尝试使用spring-boot将新用户保存到Neo4j,但遇到无法将java.lang.Long设置为我的用户域的错误。尝试了很多方法,但仍然没有运气。谁能告诉我我在做什么错?
package com.abc.userservice.domains;
import org.neo4j.ogm.annotation.GeneratedValue;
import org.neo4j.ogm.annotation.NodeEntity;
import org.springframework.data.annotation.Id;
@NodeEntity
public class User {
@Id
@GeneratedValue
private Long id;
private String fullName;
private String gender;
private String email;
private String password;
private String createdOn;
public User(){}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getCreatedOn() {
return createdOn;
}
public void setCreatedOn(String createdOn) {
this.createdOn = createdOn;
}
}
这是我的服务代码
public User createUser(User entity) {
return userRepository.save(entity);
}
这是我的控制器代码
@RequestMapping(value = "/create", method = RequestMethod.POST)
public User createUser(User user) {
return userService.createUser(user);
}
这是我的主要应用程序代码
@SpringBootApplication
@EnableNeo4jRepositories("com.abc.userservice.repositories")
@ComponentScan(basePackages = "com.abc")
@EnableTransactionManagement
public class UserServiceApplication {
public static void main(String[] args) {
SpringApplication.run(UserServiceApplication.class, args);
}
}
当我尝试保存新用户时,出现以下错误:
Can not set java.lang.Long field com.abc.userservice.domains.User.id to com.abc.userservice.domains.User
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。