您可以在打开应用程序的主类中自由编写和执行方法。yml,读取和解析它,并查找特定属性。这就是直接的Java。这就像任何其他Java类一样:
public class MyAppApplication {
public static void main(String[] args) {
// want to check the value of my property
boolean isValid = checkApplicationConfiguration("application.yml");
if (isValid) {
SpringApplication.run(MyAppApplication.class, args);
} else {
System.err.println("Invalid application.yml");
}
}
private static boolean checkApplicationConfiguration(String yamlFileName) {
// put the code to read, parse, and validate here.
}
}
显然你可以用
Jackson