我是初次使用数据jpa并尝试使用它但面临org.springframework.data.mapping.PropertyReferenceException的问题:找不到类型User的属性名称! 有人可以告诉我可以做些什么吗?我正在努力但无法找到解决方案
**Service**
public interface UserService {
Page<User> findAllUsers();
}
**Service Impl** where I am trying to implement the service methods
@Service("userService")
@Transactional
public class UserServiceImpl implements UserService{
/*@Autowired*/
@Qualifier("userDao")
private final UserDao dao;
@Autowired
public UserServiceImpl(UserDao dao) {
this.dao = dao;
}
private static final AtomicLong counter = new AtomicLong();
private static List<User> users;
public Page<User> findAllUsers() {
return dao.findAll(pageRequest);
}
**DAO**
public interface UserDao extends JpaRepository<User, Long> {
}
**User**
@Entity
@Table(name="USERAG")
public class User implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "users_seq")
private long id;
@Column(name = "NAME", nullable = true)
private String username;
@Column(name = "ADDRESS", nullable = true)
private String address;
@Column(name = "EMAIL", nullable = true)
private String email;
答案 0 :(得分:0)
我认为您删除了DAO方法。我好像记得你订购了#34; name&#34;。您的实体没有&#34; name&#34;而不是&#34; username&#34;。简而言之,它正在寻找&#34; name&#34;你的实体(你没有)