style: 优化部分 Properties 用法
This commit is contained in:
parent
5968f402ed
commit
48de2e85e0
@ -16,9 +16,8 @@
|
||||
|
||||
package top.charles7c.cnadmin.common.config.properties;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
|
||||
@ -29,8 +28,7 @@ import cn.hutool.extra.spring.SpringUtil;
|
||||
* @author Charles7c
|
||||
* @since 2022/12/21 20:21
|
||||
*/
|
||||
@Data
|
||||
@Component
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class RsaProperties {
|
||||
|
||||
/** 私钥 */
|
||||
|
@ -20,11 +20,11 @@ import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
|
||||
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;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
@ -40,10 +40,9 @@ import top.charles7c.cnadmin.common.util.ExceptionUtils;
|
||||
*/
|
||||
@Slf4j
|
||||
@Configuration
|
||||
@RequiredArgsConstructor
|
||||
@EnableConfigurationProperties(ThreadPoolProperties.class)
|
||||
public class ThreadPoolConfiguration {
|
||||
|
||||
private final ThreadPoolProperties threadPoolProperties;
|
||||
/** 核心(最小)线程数 = CPU 核心数 + 1 */
|
||||
private final int corePoolSize = Runtime.getRuntime().availableProcessors() + 1;
|
||||
|
||||
@ -52,7 +51,7 @@ public class ThreadPoolConfiguration {
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnProperty(prefix = "thread-pool", name = "enabled", havingValue = "true")
|
||||
public ThreadPoolTaskExecutor threadPoolTaskExecutor() {
|
||||
public ThreadPoolTaskExecutor threadPoolTaskExecutor(ThreadPoolProperties threadPoolProperties) {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
// 核心(最小)线程数
|
||||
executor.setCorePoolSize(corePoolSize);
|
||||
|
@ -19,7 +19,6 @@ package top.charles7c.cnadmin.common.config.threadpool;
|
||||
import lombok.Data;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 线程池配置属性
|
||||
@ -29,7 +28,6 @@ import org.springframework.stereotype.Component;
|
||||
* @since 2022/12/23 23:06
|
||||
*/
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "thread-pool")
|
||||
public class ThreadPoolProperties {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user