|
|
package com.njupt.swg.common;
|
|
|
|
|
|
import lombok.Data;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* @Author swg.
|
|
|
* @Date 2019/1/1 14:27
|
|
|
* @CONTACT 317758022@qq.com
|
|
|
* @DESC
|
|
|
* 这个类(Parameters)主要用于存放应用程序中的各类配置参数,通过Spring的依赖注入机制(@Value注解)从配置文件(通常是application.properties或application.yml等)中读取相应的值进行赋值。
|
|
|
* 它被标记为Spring的组件(@Component注解),方便在其他需要使用这些配置参数的地方通过依赖注入获取该类的实例。
|
|
|
* 同时使用了Lombok的@Data注解,自动生成了常用的Getter、Setter、toString等方法,方便对类中的属性进行操作和展示。
|
|
|
*/
|
|
|
@Component
|
|
|
@Data
|
|
|
public class Parameters {
|
|
|
|
|
|
/**
|
|
|
* Redis配置相关参数部分开始
|
|
|
* 以下是用于配置与Redis服务器连接相关的各项参数,通过@Value注解结合配置文件中的对应属性键来获取具体的值并赋值给相应的成员变量。
|
|
|
*/
|
|
|
/*****redis config start*******/
|
|
|
// 从配置文件中读取Redis服务器的主机地址配置,对应的配置文件中的属性键为"redis.host"
|
|
|
@Value("${redis.host}")
|
|
|
private String redisHost;
|
|
|
|
|
|
// 从配置文件中读取Redis服务器的端口号配置,对应的配置文件中的属性键为"redis.port",会被自动解析并赋值为整数类型
|
|
|
@Value("${redis.port}")
|
|
|
private int redisPort;
|
|
|
|
|
|
// 此处变量名可能存在混淆,按照语义理解应该是获取Redis连接池的最大空闲连接数,但变量名写的是redisMaxTotal,可能需要确认是否准确。
|
|
|
// 从配置文件中读取对应配置,配置文件中的属性键为"redis.max-idle",赋值为整数类型
|
|
|
@Value("${redis.max-idle}")
|
|
|
private int redisMaxTotal;
|
|
|
|
|
|
// 此处同样变量名可能存在混淆,按照语义理解应该是获取Redis连接池的最大连接数,但变量名写的是redisMaxIdle,可能需要核对准确性。
|
|
|
// 从配置文件中读取对应配置,配置文件中的属性键为"redis.max-total",赋值为整数类型
|
|
|
@Value("${redis.max-total}")
|
|
|
private int redisMaxIdle;
|
|
|
|
|
|
// 从配置文件中读取获取Redis连接时的最大等待时间(单位为毫秒)配置,对应的配置文件中的属性键为"redis.max-wait-millis",赋值为整数类型
|
|
|
@Value("${redis.max-wait-millis}")
|
|
|
private int redisMaxWaitMillis;
|
|
|
/*****redis config end*******/
|
|
|
|
|
|
// 用于存放不需要安全验证的管理员路径列表配置,从配置文件中读取以逗号分隔的字符串,并通过split方法解析为List<String>类型。
|
|
|
// 配置文件中对应的属性键为"security.noneSecurityAdminPaths"
|
|
|
@Value("#{'${security.noneSecurityAdminPaths}'.split(',')}")
|
|
|
private List<String> noneSecurityAdminPaths;
|
|
|
} |