꿀똥벌레
꿀똥벌레 개발 블로그
꿀똥벌레
전체 방문자
오늘
어제
  • 분류 전체보기 (90)
    • JAVA (17)
    • SPRING (14)
    • Elasticsearch (4)
    • GRADLE (2)
    • HTML, CSS (0)
    • JAVASCRIPT (0)
    • GIT (1)
    • Vue.js (1)
    • server (1)
    • Python (0)
    • IT리뷰 (0)
    • 인프라 (6)
    • IOS (21)
    • 디자인패턴 (20)
    • Kafka (1)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • maxConnTotal
  • spring integration
  • elasticsearch
  • java
  • spring
  • SWIFT
  • persistence connection
  • maxConnPerRoute
  • 인덱스 템플릿
  • Index
  • persistent connection
  • 스프링 인테그레이션
  • 엘라스틱서치
  • springintegration
  • KEEPALIVE
  • connectionRequestTimeout
  • Index Template
  • mappings
  • ES
  • 스프링 인티그레이션

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
꿀똥벌레

꿀똥벌레 개발 블로그

SPRING

SpringBoot JpaRepository 를 Dependency Scan 에서 찾지 못할때

2022. 11. 10. 15:45

현재 제 프로젝트는 멀티모듈 구조로 구성되어 있습니다.

root(@SpringBootApplication 어노테이션이 붙은 Application.java 위치)

-- shared

-- diary

-- 기타 등등..

 

JPA 설정

@ConfigurationPropertiesScan(basePackages = "com.seya330.anything")
@SpringBootApplication(scanBasePackages = "com.seya330.anything")
public class AnythingApplication {
  public static void main(String[] args) {
    SpringApplication.run(AnythingApplication.class, args);
  }
}

@Configuration
@EnableJpaRepositories(basePackages = "com.seya330.anything")
@EntityScan(basePackages = "com.seya330.anything")
@EnableJpaAuditing
public class JpaConfig {
}

shared 하위 repository 구조

아래 인터페이스 및 클래스 모두 com.seya330.anything... 하위에 위치 해 있습니다.

public interface UserProfileRepository {

  UserProfile save(UserProfile userProfile);

  Optional<UserProfile> findByEmail(String email);
}

@Repository
@RequiredArgsConstructor
public class UserProfileRepositoryImpl implements UserProfileRepository {

  private final UserProfileJpaRepository userProfileJpaRepository;

  @Override
  public UserProfile save(final UserProfile userProfile) {
    return userProfileJpaRepository.save(userProfile);
  }

  @Override
  public Optional<UserProfile> findByEmail(final String email) {
    return userProfileJpaRepository.findByEmail(email);
  }
}

public interface UserProfileJpaRepository extends CrudRepository<UserProfile, Long> {

  Optional<UserProfile> findByEmail(String email);
}

서버 구동시 이상하게 UserProfileJpaRepository 를 못찾는다는 에러메시지와 함께 서버 구동이 안됩니다..

Parameter 0 of constructor in com.seya330.anything.auth.repository.UserProfileRepositoryImpl
required a bean of type 'com.seya330.anything.auth.repository.UserProfileJpaRepository' that could not be found.

확인 해야 할 사항

  1. @EnableJpaConfig 가 잘 설정되어 있는가
  2. 스프링이 스캔할 base package 가 잘 설정되어 있는가
  3. 멀티모듈간 디펜던시가 제대로 설정되어 있는가

다 잘되어있는데.. 왜 안되는거야!!!! (diary 하위에도 똑같이 위와 같은 구조의 repository 가 있었으나, diary는 의존성 주입 잘 됨..)

 

@Builder
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class UserProfile {

  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private long id;

	....
}

@Entity 어노테이션 빠져있음.... 붙혀주니까 해결 완료..

아이고 두야..

 

저작자표시 (새창열림)

'SPRING' 카테고리의 다른 글

JPA 사용 시 Mysql 1356 Error 발생 해결 과정  (0) 2023.12.08
Spring Integration 개요  (0) 2023.06.01
Spring Retry  (0) 2022.05.18
Spring Batch FaultTolerance (장애 허용)  (0) 2021.12.13
Spring Envers 로 자동 이력 관리  (0) 2021.06.20
    꿀똥벌레
    꿀똥벌레
    개발자 꿀똥벌레 입니다.

    티스토리툴바