Giriş
Şeklen şöyle
Şeklen şöyle
Bu sınıf sadece "Inversion of Control" yeteneği sağlar. Eğer Web uygulaması yapıyorsak 
WebApplicationContext gerekir. 
Maven
Şu satırı dahil ederiz
<dependency><groupId>org.springframework</groupId><artifactId>spring-context</artifactId></dependency>
Şöyle yaparız.
 AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();constructor - Annotated Classes
Örnek
Şöyle yaparız
@Configuration@ComponentScanpublic class DemoApplication {public static void main(String[] args) {var context = new AnnotationConfigApplicationContext(DemoApplication.class);...}@Beanpublic Vertx vertx(VerticleFactory verticleFactory) {...}@Beanpublic PgPool pgPool(Vertx vertx) {...}}
Şöyle yaparız.
context.refresh();Şöyle yaparız.
String[] packages = ...;
context.scan(packages);Şöyle yaparız.
ApplicationContext parent = ...;
context.setParent(parent);
 
Hiç yorum yok:
Yorum Gönder