mirror of
				https://github.com/dromara/RuoYi-Vue-Plus.git
				synced 2025-11-04 16:23:42 +08:00 
			
		
		
		
	update 优化 所有 properties 文件改为注解启用
This commit is contained in:
		@@ -3,9 +3,9 @@ package com.ruoyi.common.core.config;
 | 
			
		||||
import com.ruoyi.common.core.config.properties.ThreadPoolProperties;
 | 
			
		||||
import com.ruoyi.common.core.utils.Threads;
 | 
			
		||||
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
 | 
			
		||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 | 
			
		||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
 | 
			
		||||
import org.springframework.context.annotation.Bean;
 | 
			
		||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 | 
			
		||||
 | 
			
		||||
@@ -19,6 +19,7 @@ import java.util.concurrent.ThreadPoolExecutor;
 | 
			
		||||
 * @author Lion Li
 | 
			
		||||
 **/
 | 
			
		||||
@AutoConfiguration
 | 
			
		||||
@EnableConfigurationProperties(ThreadPoolProperties.class)
 | 
			
		||||
public class ThreadPoolConfig {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -26,12 +27,9 @@ public class ThreadPoolConfig {
 | 
			
		||||
     */
 | 
			
		||||
    private final int core = Runtime.getRuntime().availableProcessors() + 1;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private ThreadPoolProperties threadPoolProperties;
 | 
			
		||||
 | 
			
		||||
    @Bean(name = "threadPoolTaskExecutor")
 | 
			
		||||
    @ConditionalOnProperty(prefix = "thread-pool", name = "enabled", havingValue = "true")
 | 
			
		||||
    public ThreadPoolTaskExecutor threadPoolTaskExecutor() {
 | 
			
		||||
    public ThreadPoolTaskExecutor threadPoolTaskExecutor(ThreadPoolProperties threadPoolProperties) {
 | 
			
		||||
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
 | 
			
		||||
        executor.setCorePoolSize(core);
 | 
			
		||||
        executor.setMaxPoolSize(core * 2);
 | 
			
		||||
 
 | 
			
		||||
@@ -1,13 +1,12 @@
 | 
			
		||||
package com.ruoyi.common.core.config;
 | 
			
		||||
 | 
			
		||||
import jakarta.validation.Validator;
 | 
			
		||||
import org.hibernate.validator.HibernateValidator;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
 | 
			
		||||
import org.springframework.context.MessageSource;
 | 
			
		||||
import org.springframework.context.annotation.Bean;
 | 
			
		||||
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
 | 
			
		||||
 | 
			
		||||
import jakarta.validation.Validator;
 | 
			
		||||
import java.util.Properties;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -18,14 +17,11 @@ import java.util.Properties;
 | 
			
		||||
@AutoConfiguration
 | 
			
		||||
public class ValidatorConfig {
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private MessageSource messageSource;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 配置校验框架 快速返回模式
 | 
			
		||||
     */
 | 
			
		||||
    @Bean
 | 
			
		||||
    public Validator validator() {
 | 
			
		||||
    public Validator validator(MessageSource messageSource) {
 | 
			
		||||
        LocalValidatorFactoryBean factoryBean = new LocalValidatorFactoryBean();
 | 
			
		||||
        // 国际化
 | 
			
		||||
        factoryBean.setValidationMessageSource(messageSource);
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,6 @@ package com.ruoyi.common.core.config.properties;
 | 
			
		||||
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import org.springframework.boot.context.properties.ConfigurationProperties;
 | 
			
		||||
import org.springframework.stereotype.Component;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 线程池 配置属性
 | 
			
		||||
@@ -10,7 +9,6 @@ import org.springframework.stereotype.Component;
 | 
			
		||||
 * @author Lion Li
 | 
			
		||||
 */
 | 
			
		||||
@Data
 | 
			
		||||
@Component
 | 
			
		||||
@ConfigurationProperties(prefix = "thread-pool")
 | 
			
		||||
public class ThreadPoolProperties {
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -21,6 +21,7 @@ import org.springframework.boot.autoconfigure.AutoConfiguration;
 | 
			
		||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
 | 
			
		||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 | 
			
		||||
import org.springframework.boot.autoconfigure.web.ServerProperties;
 | 
			
		||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
 | 
			
		||||
import org.springframework.context.annotation.Bean;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
@@ -35,15 +36,15 @@ import java.util.Set;
 | 
			
		||||
 */
 | 
			
		||||
@RequiredArgsConstructor
 | 
			
		||||
@AutoConfiguration(before = SpringDocConfiguration.class)
 | 
			
		||||
@EnableConfigurationProperties(SwaggerProperties.class)
 | 
			
		||||
@ConditionalOnProperty(name = "swagger.enabled", havingValue = "true", matchIfMissing = true)
 | 
			
		||||
public class SwaggerConfig {
 | 
			
		||||
 | 
			
		||||
    private final SwaggerProperties swaggerProperties;
 | 
			
		||||
    private final ServerProperties serverProperties;
 | 
			
		||||
 | 
			
		||||
    @Bean
 | 
			
		||||
    @ConditionalOnMissingBean(OpenAPI.class)
 | 
			
		||||
    public OpenAPI openApi() {
 | 
			
		||||
    public OpenAPI openApi(SwaggerProperties swaggerProperties) {
 | 
			
		||||
        OpenAPI openApi = new OpenAPI();
 | 
			
		||||
        // 文档基本信息
 | 
			
		||||
        SwaggerProperties.InfoProperties infoProperties = swaggerProperties.getInfo();
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,6 @@ import io.swagger.v3.oas.models.tags.Tag;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import org.springframework.boot.context.properties.ConfigurationProperties;
 | 
			
		||||
import org.springframework.boot.context.properties.NestedConfigurationProperty;
 | 
			
		||||
import org.springframework.stereotype.Component;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
@@ -19,7 +18,6 @@ import java.util.List;
 | 
			
		||||
 * @author Lion Li
 | 
			
		||||
 */
 | 
			
		||||
@Data
 | 
			
		||||
@Component
 | 
			
		||||
@ConfigurationProperties(prefix = "swagger")
 | 
			
		||||
public class SwaggerProperties {
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,6 @@ package com.ruoyi.common.mail.config.properties;
 | 
			
		||||
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import org.springframework.boot.context.properties.ConfigurationProperties;
 | 
			
		||||
import org.springframework.stereotype.Component;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * JavaMail 配置属性
 | 
			
		||||
@@ -10,7 +9,6 @@ import org.springframework.stereotype.Component;
 | 
			
		||||
 * @author Michelle.Chung
 | 
			
		||||
 */
 | 
			
		||||
@Data
 | 
			
		||||
@Component
 | 
			
		||||
@ConfigurationProperties(prefix = "mail")
 | 
			
		||||
public class MailProperties {
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,6 @@ import lombok.NoArgsConstructor;
 | 
			
		||||
import org.redisson.config.ReadMode;
 | 
			
		||||
import org.redisson.config.SubscriptionMode;
 | 
			
		||||
import org.springframework.boot.context.properties.ConfigurationProperties;
 | 
			
		||||
import org.springframework.stereotype.Component;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Redisson 配置属性
 | 
			
		||||
@@ -13,7 +12,6 @@ import org.springframework.stereotype.Component;
 | 
			
		||||
 * @author Lion Li
 | 
			
		||||
 */
 | 
			
		||||
@Data
 | 
			
		||||
@Component
 | 
			
		||||
@ConfigurationProperties(prefix = "redisson")
 | 
			
		||||
public class RedissonProperties {
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,9 @@
 | 
			
		||||
package com.ruoyi.common.satoken.config;
 | 
			
		||||
 | 
			
		||||
import cn.dev33.satoken.jwt.StpLogicJwtForSimple;
 | 
			
		||||
import cn.dev33.satoken.stp.StpInterface;
 | 
			
		||||
import cn.dev33.satoken.stp.StpLogic;
 | 
			
		||||
import com.ruoyi.common.satoken.core.service.SaPermissionImpl;
 | 
			
		||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
 | 
			
		||||
import org.springframework.context.annotation.Bean;
 | 
			
		||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 | 
			
		||||
@@ -20,4 +22,12 @@ public class SaTokenConfig implements WebMvcConfigurer {
 | 
			
		||||
        return new StpLogicJwtForSimple();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 权限接口实现(使用bean注入方便用户替换)
 | 
			
		||||
     */
 | 
			
		||||
    @Bean
 | 
			
		||||
    public StpInterface stpInterface() {
 | 
			
		||||
        return new SaPermissionImpl();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,6 @@ import cn.dev33.satoken.stp.StpInterface;
 | 
			
		||||
import com.ruoyi.common.core.domain.model.LoginUser;
 | 
			
		||||
import com.ruoyi.common.core.enums.UserType;
 | 
			
		||||
import com.ruoyi.common.satoken.utils.LoginHelper;
 | 
			
		||||
import org.springframework.stereotype.Component;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
@@ -14,7 +13,6 @@ import java.util.List;
 | 
			
		||||
 *
 | 
			
		||||
 * @author Lion Li
 | 
			
		||||
 */
 | 
			
		||||
@Component
 | 
			
		||||
public class SaPermissionImpl implements StpInterface {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -1,2 +1 @@
 | 
			
		||||
com.ruoyi.common.satoken.core.dao.PlusSaTokenDao
 | 
			
		||||
com.ruoyi.common.satoken.core.service.SaPermissionImpl
 | 
			
		||||
 
 | 
			
		||||
@@ -7,6 +7,7 @@ import com.ruoyi.common.security.config.properties.SecurityProperties;
 | 
			
		||||
import lombok.RequiredArgsConstructor;
 | 
			
		||||
import lombok.extern.slf4j.Slf4j;
 | 
			
		||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
 | 
			
		||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
 | 
			
		||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
 | 
			
		||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 | 
			
		||||
 | 
			
		||||
@@ -15,9 +16,11 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 | 
			
		||||
 *
 | 
			
		||||
 * @author Lion Li
 | 
			
		||||
 */
 | 
			
		||||
@RequiredArgsConstructor
 | 
			
		||||
 | 
			
		||||
@Slf4j
 | 
			
		||||
@AutoConfiguration
 | 
			
		||||
@EnableConfigurationProperties(SecurityProperties.class)
 | 
			
		||||
@RequiredArgsConstructor
 | 
			
		||||
public class SecurityConfig implements WebMvcConfigurer {
 | 
			
		||||
 | 
			
		||||
    private final SecurityProperties securityProperties;
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,6 @@ package com.ruoyi.common.security.config.properties;
 | 
			
		||||
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import org.springframework.boot.context.properties.ConfigurationProperties;
 | 
			
		||||
import org.springframework.stereotype.Component;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Security 配置属性
 | 
			
		||||
@@ -10,7 +9,6 @@ import org.springframework.stereotype.Component;
 | 
			
		||||
 * @author Lion Li
 | 
			
		||||
 */
 | 
			
		||||
@Data
 | 
			
		||||
@Component
 | 
			
		||||
@ConfigurationProperties(prefix = "security")
 | 
			
		||||
public class SecurityProperties {
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,6 @@ package com.ruoyi.common.sms.config.properties;
 | 
			
		||||
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import org.springframework.boot.context.properties.ConfigurationProperties;
 | 
			
		||||
import org.springframework.stereotype.Component;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * SMS短信 配置属性
 | 
			
		||||
@@ -11,7 +10,6 @@ import org.springframework.stereotype.Component;
 | 
			
		||||
 * @version 4.2.0
 | 
			
		||||
 */
 | 
			
		||||
@Data
 | 
			
		||||
@Component
 | 
			
		||||
@ConfigurationProperties(prefix = "sms")
 | 
			
		||||
public class SmsProperties {
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,9 @@ import cn.hutool.captcha.CaptchaUtil;
 | 
			
		||||
import cn.hutool.captcha.CircleCaptcha;
 | 
			
		||||
import cn.hutool.captcha.LineCaptcha;
 | 
			
		||||
import cn.hutool.captcha.ShearCaptcha;
 | 
			
		||||
import com.ruoyi.common.web.config.properties.CaptchaProperties;
 | 
			
		||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
 | 
			
		||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
 | 
			
		||||
import org.springframework.context.annotation.Bean;
 | 
			
		||||
import org.springframework.context.annotation.Lazy;
 | 
			
		||||
 | 
			
		||||
@@ -16,6 +18,7 @@ import java.awt.*;
 | 
			
		||||
 * @author Lion Li
 | 
			
		||||
 */
 | 
			
		||||
@AutoConfiguration
 | 
			
		||||
@EnableConfigurationProperties(CaptchaProperties.class)
 | 
			
		||||
public class CaptchaConfig {
 | 
			
		||||
 | 
			
		||||
    private static final int WIDTH = 160;
 | 
			
		||||
 
 | 
			
		||||
@@ -4,13 +4,13 @@ import com.ruoyi.common.core.utils.StringUtils;
 | 
			
		||||
import com.ruoyi.common.web.config.properties.XssProperties;
 | 
			
		||||
import com.ruoyi.common.web.filter.RepeatableFilter;
 | 
			
		||||
import com.ruoyi.common.web.filter.XssFilter;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import jakarta.servlet.DispatcherType;
 | 
			
		||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
 | 
			
		||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 | 
			
		||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
 | 
			
		||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
 | 
			
		||||
import org.springframework.context.annotation.Bean;
 | 
			
		||||
 | 
			
		||||
import jakarta.servlet.DispatcherType;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
@@ -20,22 +20,20 @@ import java.util.Map;
 | 
			
		||||
 * @author Lion Li
 | 
			
		||||
 */
 | 
			
		||||
@AutoConfiguration
 | 
			
		||||
@EnableConfigurationProperties(XssProperties.class)
 | 
			
		||||
public class FilterConfig {
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private XssProperties xssProperties;
 | 
			
		||||
 | 
			
		||||
    @SuppressWarnings({"rawtypes", "unchecked"})
 | 
			
		||||
    @Bean
 | 
			
		||||
    @ConditionalOnProperty(value = "xss.enabled", havingValue = "true")
 | 
			
		||||
    public FilterRegistrationBean xssFilterRegistration() {
 | 
			
		||||
    public FilterRegistrationBean xssFilterRegistration(XssProperties xssProperties) {
 | 
			
		||||
        FilterRegistrationBean registration = new FilterRegistrationBean();
 | 
			
		||||
        registration.setDispatcherTypes(DispatcherType.REQUEST);
 | 
			
		||||
        registration.setFilter(new XssFilter());
 | 
			
		||||
        registration.addUrlPatterns(StringUtils.split(xssProperties.getUrlPatterns(), ","));
 | 
			
		||||
        registration.setName("xssFilter");
 | 
			
		||||
        registration.setOrder(FilterRegistrationBean.HIGHEST_PRECEDENCE);
 | 
			
		||||
        Map<String, String> initParameters = new HashMap<String, String>();
 | 
			
		||||
        Map<String, String> initParameters = new HashMap<>();
 | 
			
		||||
        initParameters.put("excludes", xssProperties.getExcludes());
 | 
			
		||||
        registration.setInitParameters(initParameters);
 | 
			
		||||
        return registration;
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,6 @@ import com.ruoyi.common.web.enums.CaptchaCategory;
 | 
			
		||||
import com.ruoyi.common.web.enums.CaptchaType;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import org.springframework.boot.context.properties.ConfigurationProperties;
 | 
			
		||||
import org.springframework.stereotype.Component;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 验证码 配置属性
 | 
			
		||||
@@ -12,7 +11,6 @@ import org.springframework.stereotype.Component;
 | 
			
		||||
 * @author Lion Li
 | 
			
		||||
 */
 | 
			
		||||
@Data
 | 
			
		||||
@Component
 | 
			
		||||
@ConfigurationProperties(prefix = "captcha")
 | 
			
		||||
public class CaptchaProperties {
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,6 @@ package com.ruoyi.common.web.config.properties;
 | 
			
		||||
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import org.springframework.boot.context.properties.ConfigurationProperties;
 | 
			
		||||
import org.springframework.stereotype.Component;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * xss过滤 配置属性
 | 
			
		||||
@@ -10,7 +9,6 @@ import org.springframework.stereotype.Component;
 | 
			
		||||
 * @author Lion Li
 | 
			
		||||
 */
 | 
			
		||||
@Data
 | 
			
		||||
@Component
 | 
			
		||||
@ConfigurationProperties(prefix = "xss")
 | 
			
		||||
public class XssProperties {
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -21,10 +21,8 @@ import org.springframework.context.annotation.Configuration;
 | 
			
		||||
@ConditionalOnProperty(prefix = "xxl.job", name = "enabled", havingValue = "true")
 | 
			
		||||
public class XxlJobConfig {
 | 
			
		||||
 | 
			
		||||
    private final XxlJobProperties xxlJobProperties;
 | 
			
		||||
 | 
			
		||||
    @Bean
 | 
			
		||||
    public XxlJobSpringExecutor xxlJobExecutor() {
 | 
			
		||||
    public XxlJobSpringExecutor xxlJobExecutor(XxlJobProperties xxlJobProperties) {
 | 
			
		||||
        log.info(">>>>>>>>>>> xxl-job config init.");
 | 
			
		||||
        XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
 | 
			
		||||
        xxlJobSpringExecutor.setAdminAddresses(xxlJobProperties.getAdminAddresses());
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user