spring boot에서 @repository가 주입이 안됩니다.
글쓴이: ehaakdl / 작성시간: 금, 2020/10/09 - 10:46오후
spring boot에서 @repository 인터페이스가 주입이 안되서 질문 올립니다.
해당 인터페이스를 사용하는 클래스에서 필드에 @Autowired로 주입을 시도 했습니다만 nullexception
발생하고 원인을 알 수 없어서 올려봅니다.
@Repository
public interface AccountInfoRepo extends JpaRepository<AccountInfoTb, String>{
@Override
Optional<AccountInfoTb> findById(String id);
}@Entity
@Table(name="member_info_tb")
public class AccountInfoTb {
public AccountInfoTb(){
}
public AccountInfoTb(String mPassword, String mUsername, String mEmail) {
this.mPassword = mPassword;
this.mUsername = mUsername;
this.mEmail = mEmail;
}
@Column(name = "member_passwd", nullable=false, length=256, columnDefinition = "varchar2")
private String mPassword;
@Id
@Column(name = "member_id", nullable=false, length=15, columnDefinition = "nvarchar2")
private String mUsername;
public String getmEmail() {
return mEmail;
}
@Column(name = "member_email", nullable=false, length=320, columnDefinition = "nvarchar2")
private String mEmail;
public String getmPassword() {
return mPassword;
}
public String getmUsername() {
return mUsername;
}
}실제 null 발생하는 코드 입니다. 위에는 해당 타입의 정의구요
public class AccountAuthService implements UserDetailsService {
@Autowired
private AccountInfoRepo accountInfoRepo;
private AccountInfoTb findById(String id) throws Exception{
AccountInfoTb accountInfo = null;
try {
accountInfo = accountInfoRepo.findById(id).get();
} catch (IllegalArgumentException except){
throw (Exception) new Exception().initCause(except);
} catch (NoSuchElementException except){
throw (Exception) new Exception().initCause(except);
} catch (NullPointerException except){
throw (Exception) new Exception().initCause(except);
}
return accountInfo;
}
}Forums:


해결했습니다.
.
댓글 달기