@Configuration
public class AppBasicConfig {
static {
//全局禁用 fastjson 循环引用检测
JSON.DEFAULT_GENERATE_FEATURE |= SerializerFeature.DisableCircularReferenceDetect.getMask();
}
@Bean(name = "xxxExecutor")
public Executor homepageRemindExecutor(@Value("${other.executor.xxx.corePoolSize:200}") Integer corePoolSize,
@Value("${other.executor.xxx.maximumPoolSize:1500}") Integer maximumPoolSize,
@Value("${other.executor.xxx.keepAliveTime:60}") Long keepAliveTime,
@Value("${other.executor.xxx.capacity:5000}") Integer capacity) {
Executor executor = TtlExecutors.getTtlExecutorService(ThreadUtils.newBuilder("xxx-pool")
.linkedQueue()
.keepAliveTime(keepAliveTime, TimeUnit.SECONDS)
.maximumPoolSize(maximumPoolSize)
.corePoolSize(corePoolSize)
.buildTtl());
return executor;
}
}
@Service
public class XClass{
@Resource
private mExecutor xxxExecutor;
public void func(){
CompletableFuture.supplyAsync(supplier, xxxExecutor);
CompletableFuture.supplyAsync(()->{
// xxx逻辑;
}, xxxExecutor);
}
}
(类型转换)类名后缀 Wrapper , 注解 @Mapper(componentModel = “spring”)