작성
·
345
0
Error creating bean with name 'memberRepository' defined in study.datajpa.repository.MemberRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Invocation of init method failed; nested exception is org.springframework.data.repository.query.QueryCreationException: Could not create query for public abstract java.util.List study.datajpa.repository.MemberRepository.findProjectionsByUsername(java.lang.String)! Reason: Failed to create query for method public abstract java.util.List study.datajpa.repository.MemberRepository.findProjectionsByUsername(java.lang.String)! null; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract java.util.List study.datajpa.repository.MemberRepository.findProjectionsByUsername(java.lang.String)! null
이렇게 repository에서 저 네임메서드가 생성이 안되어서 오류가 뜨는데 해결이 안됩니다..
답변 2
1
@Entity
@Getter
@Setter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@ToString(of = {"id","username","team"})
public class Member extends BaseEntity{
@Id @GeneratedValue
@Column(name = "member_id")
private Long id;
private String username;
private int age;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "team_id")
private Team team;
public Member(String username) {
this.username = username;
}
public Member(String username, int i, Team team) {
this.username = username;
this.age = i;
if(team!=null){
changeTeam(team);
}
}
public Member(String username, int age) {
this(username, age, null);
}
public void changeTeam(Team team){
this.team = team;
team.getMembers().add(this);
}
}
혹시 Spring Data Jpa 버전이 최신버전이실까요?
만약 최신버전이시라면 아래 글 답변을 참고하셔서 Spring Boot 버전 또는 Spring Data Jpa 버전을 낮춰보시고 다시 시도해주시겠어요?