1.yaml文件示例:
england:
initialUrl: https://www.leisu.com/data/zuqiu/comp-82
finalUrl: https://www.dszuqiu.com/league/35
filePath:
fileName: "英超.xlsx"
spain:
initialUrl: https://www.leisu.com/data/zuqiu/comp-120
finalUrl: https://www.dszuqiu.com/league/36
filePath:
fileName: "西甲.xlsx"
australia:
initialUrl: https://www.leisu.com/data/zuqiu/comp-590
finalUrl: https://www.dszuqiu.com/league/3
filePath:
fileName: "澳超.xlsx"
2.配置pom.xml
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.27</version>
</dependency>
3.读取yaml文件示例代码:
public class Main {标签:Map,www,Java,读取,yaml,Yaml,https,com From: https://www.cnblogs.com/michaelShao/p/18553275
public static void main(String[] args) throws IOException, URISyntaxException, InterruptedException, NoSuchAlgorithmException, KeyManagementException {
//解析yml文件的关键类
FileInputStream inputStream = new FileInputStream(new File("jobParam.yaml"));
Yaml yml = new Yaml();
Map<String,Object> obj = (Map)yml.load(inputStream);
Map<String,Object> baseInfo =(Map)obj.get("england");
System.out.println(baseInfo.get("initialUrl"));
}
}