#Reports
reports:
PnLReport:
reportId: 10
path: \\\\pathto\\PnLreport\\
BalanceSheetReport:
reportId: 11
path: \\\\pathto\\balancesheet\\
schedule-10:
description: Deliver pnl reports
report: 10
format: PDF, XLS我在我的application.yml应用程序中的Spring Boot文件中定义了上述属性。
repordId和path属性映射到enum。例如:
公共枚举ReportType{ PNL(.)余额(.);私有最终字符串reportId;私有最终字符串路径;私有ReportType(字符串reportId,字符串路径){ this.identifier =标识符;}report: 10属性下的schedule-10属性下的reportId之间映射到reportId,以派生FileService类中的路径,这样我就可以查看路径中是否存在这些文件。我怎样才能完成这个映射?发布于 2017-10-18 06:55:27
我不确定我是否建议为此使用枚举,因为您要寻找的更像是一个可配置的属性实例。也许可以考虑使用一个简单的类,然后读取其中的两个实例?
public class ReportType {
private Integer reportId;
private String path;
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public void getReportId() {
return reportId;
}
public Integer setReportId(Integer reportId) {
this.reportId = reportId;
}
}
@Component
@ConfigurationProperties(prefix = "reports")
public class ReportTypes {
public ReportType PlnReport;
public ReportType BalanceSheetReport;
}https://stackoverflow.com/questions/46340636
复制相似问题