본문 바로가기

spring/Annotation

@ComponentScan

스프링 설정파일에서 


<context:component-scan base-package="package.pack1" />


와 같이 component scan을 하게 된다.


Class에서 다른 Class 타입의 객체를 사용하기 위해서 사용한다.


:

@ComponentScan("package.pack2")

public class Pack1Class{

:


Pack1Class class에서 package.pack2 패키지의 component 객체를 참조하기 위해서 어노테이션으로 scan한다.


xml 설정파일에서 scan하던 일을 어노테이션으로 처리한 것이다.


이경우 xml 설정파일에서 scan하지 않아도 된다.

'spring > Annotation' 카테고리의 다른 글

@Scope - @Component 옵션  (0) 2014.05.07
@Value, Spring EL  (0) 2014.05.07
@Resource  (0) 2014.05.02
어노 테이션을 사용하기 위한 설정  (0) 2014.05.02
@component : @Service,@Repository,@Controller  (0) 2014.05.02