티스토리 뷰

 

에러 원인 : Spring Bean 생성 에러

 

에러 로그

Error creating bean with name 'boardController' defined in file 
[/Users/daon/git/springboot-jpa-project/build/classes/java/main
/com/example/jpa/controller/BoardController.class]: 
Unsatisfied dependency expressed through constructor parameter 0; 
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: 
Error creating bean with name 'boardService' defined in file 
[/Users/daon/git/springboot-jpa-project/build/classes/java/main
/com/example/jpa/service/BoardService.class]: 
Unsatisfied dependency expressed through constructor parameter 0; 
nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'boardRepository' defined in 
com.example.jpa.repository.BoardRepository defined in @EnableJpaRepositories 
declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: 
Invocation of init method failed; 
nested exception is java.lang.IllegalArgumentException: 
This class [class com.example.jpa.entity.BaseEntity] does not define an IdClass

 

 

 

해당 에러는 '빈 생성시에 필요한 것이 빠졌거나, 잘못되었으니 고쳐라' 라는 에러를 뱉고 있다.

로그에서 알려주는 클래스에서 어노테이션이나 지정해준 것을 확인해봤더니 BoardRepository에서 아래와 같이 <BoardEntity, Long> 으로 지정해줘야 하는 것을 BoardEntity 대신에 BaseEntity로 지정해서 빈 생성이 되지 않았던 것이었다. 

 

 

 

import com.example.jpa.entity.BoardEntity;
import org.springframework.data.jpa.repository.JpaRepository;

public interface BoardRepository extends JpaRepository<BoardEntity, Long> { 
}

 

 

 

다시 알맞게 수정을 하고 실행을 했더니 (hibernate는 create로 실행함)

// application.yml
hibernate:
  ddl-auto: update

 

 

 

drop된 후 다시 create table이 잘 만들어졌다. 

실행이 잘 된 것을 보고 application.yml 은 update로 다시 변경해주었다. 

 

 

 

테이블 생성 화면

 

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/09   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
글 보관함