mirror of
https://gitee.com/dromara/sms4j.git
synced 2025-12-06 08:58:38 +08:00
spring Bean不在全量加载,而是按需加载
This commit is contained in:
parent
fc2003f8fe
commit
4ec15b8ad4
@ -11,6 +11,7 @@ import org.dromara.sms4j.starter.utils.SmsSpringUtil;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
@ -36,18 +37,21 @@ public class SmsAutowiredConfig {
|
||||
|
||||
/** 注入一个定时器*/
|
||||
@Bean
|
||||
@Lazy
|
||||
protected DelayedTime delayedTime(){
|
||||
return BeanFactory.getDelayedTime();
|
||||
}
|
||||
|
||||
/** 注入线程池*/
|
||||
@Bean("smsExecutor")
|
||||
@Lazy
|
||||
protected Executor taskExecutor(SmsConfig config){
|
||||
return BeanFactory.setExecutor(config);
|
||||
}
|
||||
|
||||
/** 注入一个配置文件读取工具*/
|
||||
@Bean
|
||||
@Bean("smsConfigUtil")
|
||||
@Lazy
|
||||
protected ConfigUtil configUtil(Environment environment){
|
||||
return new ConfigUtil(environment);
|
||||
}
|
||||
|
||||
@ -13,61 +13,73 @@ import org.dromara.sms4j.yunpian.config.YunPianFactory;
|
||||
import org.dromara.sms4j.zhutong.config.ZhutongFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
|
||||
@Configuration
|
||||
public class SmsProviderFactoryConfig {
|
||||
|
||||
@Bean
|
||||
@Lazy
|
||||
public AlibabaFactory smsAlibabaFactory() {
|
||||
return AlibabaFactory.instance();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Lazy
|
||||
public CloopenFactory smsCloopenFactory() {
|
||||
return CloopenFactory.instance();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Lazy
|
||||
public CtyunFactory smsCtyunFactory() {
|
||||
return CtyunFactory.instance();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Lazy
|
||||
public EmayFactory smsEmayFactory() {
|
||||
return EmayFactory.instance();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Lazy
|
||||
public HuaweiFactory smsHuaweiFactory() {
|
||||
return HuaweiFactory.instance();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Lazy
|
||||
public JdCloudFactory smsJdCloudFactory() {
|
||||
return JdCloudFactory.instance();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Lazy
|
||||
public NeteaseFactory smsNeteaseFactory() {
|
||||
return NeteaseFactory.instance();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Lazy
|
||||
public TencentFactory smsTencentFactory() {
|
||||
return TencentFactory.instance();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Lazy
|
||||
public UniFactory smsUniFactory() {
|
||||
return UniFactory.instance();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Lazy
|
||||
public YunPianFactory smsYunPianFactory() {
|
||||
return YunPianFactory.instance();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Lazy
|
||||
public ZhutongFactory smsZhutongFactory() {
|
||||
return ZhutongFactory.instance();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user