[JPA] No property 'Method Name' found for type 'Class Name'!
아무것도 안 보고 무지성으로 하려 하니 다채로운 오류가 많이 발생한다. 그리고 이는 좀 많이 슬프다..
springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'manageController' defined in file [C:\Devroot\spring-workspace\board\board\out\production\classes\com\eleven\board\controller\ManageController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'manageServiceImpl' defined in file [C:\Devroot\spring-workspace\board\board\out\production\classes\com\eleven\board\service\ManageServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'manageRepository' defined in com.eleven.board.repository.ManageRepository 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 com.eleven.board.domain.ManageAd com.eleven.board.repository.ManageRepository.findAd(int)! Reason: Failed to create query for method public abstract com.eleven.board.domain.ManageAd com.eleven.board.repository.ManageRepository.findAd(int)! No property 'findAd' found for type 'ManageAd'!; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract com.eleven.board.domain.ManageAd com.eleven.board.repository.ManageRepository.findAd(int)! No property 'findAd' found for type 'ManageAd'!
에러 메시지 제일 마지막 부분을 보면 No property 'findAd' found for type 'ManageAd'!라고 되어있다.
ManageAd findAd(int uid);
실제 코드에서 ManageAd(DTO이다.)는 올바르게 import 되어있는데 왜 DTO를 못 찾지라고 생각했는데, 내가 무의식적으로 By를 작성했다고 생각했지만 By가 써져있지 않았다.
JPA 사용 시 특정 값을 사용해 SELECT 하기 위해서는 메서드명에 findBy가 붙어있어야 한다.
그리고 웬만하면 JPA이든, MyBatis든 쿼리와 관련해서 문제가 있으면 Controller와 Service가 제대로 정의되어있지 않다고 먼저 오류를 발생시킨다.
따라서 오류 내용을 처음부터 훑는 것보단 제일 아래 부분을 먼저 보는 게 더 빠르게 해결할 수 있다.
[JPA] No property 'Method Name' found for type 'Class Name'!
아무것도 안 보고 무지성으로 하려 하니 다채로운 오류가 많이 발생한다. 그리고 이는 좀 많이 슬프다..
springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'manageController' defined in file [C:\Devroot\spring-workspace\board\board\out\production\classes\com\eleven\board\controller\ManageController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'manageServiceImpl' defined in file [C:\Devroot\spring-workspace\board\board\out\production\classes\com\eleven\board\service\ManageServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'manageRepository' defined in com.eleven.board.repository.ManageRepository 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 com.eleven.board.domain.ManageAd com.eleven.board.repository.ManageRepository.findAd(int)! Reason: Failed to create query for method public abstract com.eleven.board.domain.ManageAd com.eleven.board.repository.ManageRepository.findAd(int)! No property 'findAd' found for type 'ManageAd'!; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract com.eleven.board.domain.ManageAd com.eleven.board.repository.ManageRepository.findAd(int)! No property 'findAd' found for type 'ManageAd'!
에러 메시지 제일 마지막 부분을 보면 No property 'findAd' found for type 'ManageAd'!라고 되어있다.
ManageAd findAd(int uid);
실제 코드에서 ManageAd(DTO이다.)는 올바르게 import 되어있는데 왜 DTO를 못 찾지라고 생각했는데, 내가 무의식적으로 By를 작성했다고 생각했지만 By가 써져있지 않았다.
JPA 사용 시 특정 값을 사용해 SELECT 하기 위해서는 메서드명에 findBy가 붙어있어야 한다.
그리고 웬만하면 JPA이든, MyBatis든 쿼리와 관련해서 문제가 있으면 Controller와 Service가 제대로 정의되어있지 않다고 먼저 오류를 발생시킨다.
따라서 오류 내용을 처음부터 훑는 것보단 제일 아래 부분을 먼저 보는 게 더 빠르게 해결할 수 있다.