728x90
내가 뜬 오류는 바로
@org.springframework.beans.factory.annotation.Autowired(required=true)
문제는 패키지 구성의 문제가 있었다.
레포지토리는 repository에 있었고 그 레포지토리를 이용한 의존성 주입은 pach에서 했었다. 우선 SpringblogApplicaiton이 실행파일인데 이 실행 파일에 있는
@SpringBootApplication()
어노테이션은 지금 있는 패키지를 root로 올려 의존성을 뿌리는 것 같다. 때문에 pach에서 레포지토리를 가져와서 의존성을 주입하려니까 안되는 것이다.
위처럼 같은 패키지에 넣어주니 해결되었다. 또는 test 패키지 하위 폴더로 구성하면 될 것이다. 아마 이전포스팅에서 찾지 못해서 경로를 정해주었던 것도 이게 루트라서 그런 것 같다. 하위 패키지로 해주면
@EntityScan(basePackages = {"com.cho.springblog.model"})
@EnableJpaRepositories(basePackages = {"com.cho.springblog.repository"})
이 어노테이션을 사용하지 않아도 될 것 같다.
'Dev > Spring Boot' 카테고리의 다른 글
[오류]Error creating bean with name 'springSecurityFilterChain' defined in class path resource (0) | 2023.01.25 |
---|---|
Spring Boot - 용어 정리 (0) | 2023.01.23 |
Spring Boot - JSON으로 통신 (0) | 2023.01.19 |
IntelliJ에서 자동 빌드 세팅 (Hot Reload) (0) | 2023.01.13 |
Spring Boot - Bean 을 찾지 못하는 에러(Consider defining a bean of type) (0) | 2023.01.13 |