현재 제 프로젝트는 멀티모듈 구조로 구성되어 있습니다.
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.
확인 해야 할 사항
- @EnableJpaConfig 가 잘 설정되어 있는가
- 스프링이 스캔할 base package 가 잘 설정되어 있는가
- 멀티모듈간 디펜던시가 제대로 설정되어 있는가
다 잘되어있는데.. 왜 안되는거야!!!! (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 |