You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tet/snailmall-api-gateway/src/main/java/com/njupt/swg/common/Parameters.java

54 lines
2.9 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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;
}