부자 되기 위한 블로그, 머니킹

 

 

MemberRepository java 코드

public interface MemberRepository extends JpaRepository<Member,Long> {
    public Member findByEmail(String email);
    public Member findByName(String name);
}

 

Member 코드

package com.jelly_develop.passprofile.domain.member;

import com.sun.istack.NotNull;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.validation.constraints.NotEmpty;

@Getter @Setter
@Slf4j
@Entity
public class Member {

    @Id @GeneratedValue
    @Column(name="member_id")
    private Long id;
    @NotEmpty
    private String email;
    @Column(name="member_password")
    @NotEmpty
    private String password;
    private String username;
    private String phone;
    private int age;

    public Member(String email, String password, String username, String phone, int age) {
        this.email = email;
        this.password = password;
        this.username = username;
        this.phone = phone;
        this.age = age;
    }

    public Member() {
    }



}

 

변수 선언이 username으로 있었는데 JPA 형식에서 findByName으로 쓴게 오류의 원인이었습니다.

findByUsername으로 바꾸니깐 잘 됩니다.

오류 메시지를 잘 확인하자.. ㅜ