2. XML이나 Annotation 두 가지 방법 중 하나를 선택할 수 있습니다.
XML : <context:component-scan>
Annotation : @ComponentScan
3. base 패키지를 지정할 수 있습니다.
//=================================원문=================================//
org.springframework.context.annotation
Annotation Type ComponentScan
@Retention(value=RUNTIME) @Target(value=TYPE) @Documented @Repeatable(value=ComponentScans.class) public @interface ComponentScan
Configures component scanning directives for use with @Configuration
classes. Provides support parallel with Spring XML's<context:component-scan>
element.EitherbasePackageClasses()
orbasePackages()
(or its aliasvalue()
) may be specified to define specific packages to scan. If specific packages are not defined, scanning will occur from the package of the class that declares this annotation.
Note that the<context:component-scan>
element has anannotation-config
attribute; however, this annotation does not. This is because in almost all cases when using@ComponentScan
, default annotation config processing (e.g. processing@Autowired
and friends) is assumed. Furthermore, when usingAnnotationConfigApplicationContext
, annotation config processors are always registered, meaning that any attempt to disable them at the@ComponentScan
level would be ignored.
See@Configuration
's Javadoc for usage examples.- Since:
- 3.1
- Author:
- Chris Beams, Juergen Hoeller, Sam Brannen
- link:
- http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/context/annotation/ComponentScan.html
댓글 없음:
댓글 쓰기