在项目开发的过程中,有很多的配置需要设置,但是我们又不能全部写在application.yml中。所以需要我们重新设置一个配置文件,一般情况下会划分为:业务文件和系统文件。
配置文件一般我们放在 resources目录下,例如我们要添加个system-config.yml文件:如下图
内容如下:
system:
test:
hahah
#登录拦截器
whitlelist:
- /auth/login
- /auth/logout
- /category/alltree
- /error
tokenExpire: 18000
项目中使用:
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
/**
* @ClassName SystemConfig
* @Author johnny xia
* @mailto [email protected]
* @Date 2019-07-02 10:19
* @Description 系统配置文件
**/
@Data
@Component
@ConfigurationProperties(prefix = "system")
public class SystemConfig {
private int tokenExpire;
/**
* 登录拦截器白名单
*/
private List<String> whitlelist = new ArrayList<>();
}