1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| package com.spricoder.mysdk;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration;
@Configuration
@EnableConfigurationProperties(MySDKSource.class)
@ConditionalOnProperty(name = "mysdk.enable", havingValue = "enable") public class MySDKAutoConfiguration { @Autowired private MySDKSource mySDKSource;
@Bean @ConditionalOnMissingBean(MySDKSource.class) public MySDKService mySDKService(){ return new MySDKService(mySDKSource); } }
|