nacos配置
path:
work: work
study: study
配置类
@RefreshScope
@ConfigurationProperties(prefix = "path")
public class PathProperties {
@Getter
private static String work;
@Getter
private static String study;
public void setWork(String workPath) {
PathProperties.work = workPath;
}
public void setStudy(String studyPath) {
PathProperties.study = studyPath;
}
}
枚举类
@Getter
@AllArgsConstructor
public enum PathEnum {
WORK("1", PathProperties::getWork),
STUDY("2", PathProperties::getStudy);
private final String type;
private final Supplier<String> pathSupplier;
public String getPath() {
return pathSupplier.get();
}
}