@Configuration
Spring Framework가 해당 클래스를 구성 클래스로 인식하고 구성을 위해 사용한다.
다른클래스에서 @Autowired로 Bean을 부를 수 있다.
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class MyConfiguration {
@Bean
public MyBean myBean() {
return new MyBean();
}
}
MyBean의 인스턴스를 생성하고 이를 애플리케이션의 다른 구성요소에서 사용할 수 있다.
구성클래스에는 빈, 데이터베이스연결 등이 포함될 수 있다.
https://standout.tistory.com/477
Annotation - @Autowired @Qualifier
@Autowired 메서드 파라미터에 맞는 타입의 빈을 찾아서 자동으로 주입 의존성 주입(Dependency Injection)을 자동화하는 데 사용되는 어노테이션 속성(field), setter method, constructor(생성자)에서 사용된다. @
standout.tistory.com
https://standout.tistory.com/474
Annotation - @Bean @Scope
@Bean 빈은 Spring 컨테이너에서 생성되고 관리되는 객체 개발자가 직접 제어가 불가능한 외부 라이브러리등을 Bean으로 만들려할 때 주로 사용된다. @Configuration public class MyConfiguration { @Bean public MyBe
standout.tistory.com
'JAVA > Spring' 카테고리의 다른 글
Annotation - @SpringBootApplication (0) | 2023.04.20 |
---|---|
Annotation - @ComponentScan (0) | 2023.04.20 |
Annotation - @Repository (0) | 2023.04.19 |
Annotation - @Service (0) | 2023.04.19 |
Annotation - @PostMapping (0) | 2023.04.19 |