[Error] Could not autowire. No beans of 'xxxx' type found.

2023. 5. 10. 00:50·Error

# 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

  • https://docs.spring.io/spring-boot/docs/current/reference/html/using.html#using.using-the-springbootapplication-annotation
 

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

  • https://www.baeldung.com/spring-component-scanning

 

'Error' 카테고리의 다른 글

[Error] Field repository in required a bean of type 'xxx' that could not be found.  (0) 2023.05.11
'Error' 카테고리의 다른 글
  • [Error] Field repository in required a bean of type 'xxx' that could not be found.
Log Cat
Log Cat
잊어버리지 않기 위한 메모장
  • Log Cat
    개발 메모장
    Log Cat
  • 전체
    오늘
    어제
    • 전체보기 (45) N
      • Book Review (6)
      • Language (15) N
        • Java (10) N
        • Go (1)
        • JavaScript (1)
        • TypeScript (3)
      • Computer Science (3)
        • Network (1)
        • Database (1)
        • Design Pattern (0)
      • Spring Framework (10)
        • Spring & Spring Boot (4)
        • Spring Batch (4)
        • Servlet & JSP (2)
      • Python Framework (3)
        • FastAPI (3)
      • Infra (3)
        • Dcoker (1)
        • Kafka (2)
      • ORM (1)
        • JPA (1)
      • Fun (1) N
      • Error (2)
      • Retrospective (0)
      • Certificate (1)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

    • Github
  • 인기 글

  • 태그

    코테
    Typescript
    effective java 3/e
    리트코드
    fastapi
    우아한테크코스
    성공과 실패를 결정하는 1%의 네트워크 원리
    프로그래머스 문제
    네트워크 원리
    자바
    백준
    jvm
    spring kafka
    escape-analysis
    프로그래머스
    BOJ
    코딩테스트
    Python
    개발서적리뷰
    이팩티브 자바
    leetcode
    자바 풀이
    spring boot
    jmm
    spring
    프로그래머스문제
    개발서적
    네트워크
    programmers
    Java
  • 최근 글

  • hELLO· Designed By정상우.v4.10.6
Log Cat
[Error] Could not autowire. No beans of 'xxxx' type found.
상단으로

티스토리툴바