# Error
Intellij에서 @Component를 부여한 클래스의 인스턴스를 @Autowired를 통해 사용하는 클래스의 필드에 주입하려면
'Could not autowire. No beans of 'xxxx' type found.'의 error가 발생한다.
# Solution
@ComponentScan을 통해 패키지의 @Component 을 스캔할 수 있다.
@SpringBootApplication
@ComponentScan(basePackages = { "path of package ex) com.demo" })
public class DemoApplication {
public static void main(String[] args) {
...
}
@Autowired
Sample sample;
}
# Reference
Developing with Spring Boot
This section goes into more detail about how you should use Spring Boot. It covers topics such as build systems, auto-configuration, and how to run your applications. We also cover some Spring Boot best practices. Although there is nothing particularly spe
docs.spring.io
'Error' 카테고리의 다른 글
[Error] Field repository in required a bean of type 'xxx' that could not be found. (0) | 2023.05.11 |
---|