Giriş
Şeklen şöyle
Auto Configuration kapsamında 3 tane seçenek var
1. @ConditionalOnClass
2. @Conditional
3. @ConditionalOnProperty
4. @ConditionalOnMissingBean
Örnek
Şöyle yaparız
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;@Configuration@ConditionalOnClass(GreeterService.class)public class GreeterServiceAutoConfiguration {@Bean@ConditionalOnMissingBeanpublic GreeterService greeterService() {return new GreeterService("Welcome", "Mr");}}
Hiç yorum yok:
Yorum Gönder