Giriş
Şu satırı dahil ederiz.
Örnek
Şöyle yaparız.
Birden fazla paket vermek için şöyle yaparız.
XML ile şöyle yaparız.
XML ile şöyle yaparız.
Sadece @Controller ve @ControllerAdvice anotasyonuna sahip sınıfları yüklemek için şöyle yaparız.
Şu satırı dahil ederiz.
import org.springframework.context.annotation.ComponentScan;Açıklaması şöyle.If specific packages are not defined, scanning will occur from the package of the class that declares this annotation.
@ComponentScan will give you a list of all the classes with the @Component, @Service, @Repository annotation in a packagebasePackages Alanı
Örnek
Şöyle yaparız.
@Configuration
@ComponentScan({"my.packages"})
public class AppManager {
  @Bean(name = "jmxExporter")
  public Exporter jmxExporter() {
    return new Exporter();
  }
}Birden fazla paket vermek için şöyle yaparız.
@ComponentScan({"edu.miis.Controllers","edu.miis.Service","edu.miis.Dao"})XML ile şöyle yaparız.
<context:component-scan base-package="com.test.chomage" />XML ile şöyle yaparız.
<context:component-scan
  base-package="com.example.project"
  scope-resolver="org.springframework.context.annotation.Jsr330ScopeMetadataResolver">
  <context:include-filter type="annotation" expression="javax.ejb.Stateless"/>
</context:component-scan>Sadece @Controller ve @ControllerAdvice anotasyonuna sahip sınıfları yüklemek için şöyle yaparız.
@Configuration
@ComponentScan(
    basePackages = { ... },
    excludeFilters = {
        @ComponentScan.Filter(type=FilterType.ANNOTATION, value=Controller.class),
        @ComponentScan.Filter(type=FilterType.ANNOTATION, value=ControllerAdvice.class)
    }
) 
Hiç yorum yok:
Yorum Gönder