등록하는 법

Component Scan

스프링부트로 만든 애플리케이션은 대부분 @SpringBootApplication이 붙은 부분이 있고 이 안에 @ComponentScan이 있다.

모든 패키지에 @Component라는 어노테이션을 찾아서 빈으로 만들어 준다.

직접 등록

@SpringBootApplication
public class ..

	@Bean
	public String hello() {
		return "hello";
	}
@Autowired
String hello;

System.out.println(hello); // hello