@SpringBootTest public class OtherTest { @Test @SneakyThrows void contextLoads9() { YamlPropertiesFactoryBean yamlPropertiesFactoryBean = new YamlPropertiesFactoryBean(); // yamlPropertiesFactoryBean.setResources(new FileUrlResource("E:\\IDEA_Project\\Prosonal\\spirngboot226\\src\\main\\resources\\test.yml")); yamlPropertiesFactoryBean.setResources(new ClassPathResource("test.yml"),new ClassPathResource("test2.yml")); Properties properties = yamlPropertiesFactoryBean.getObject(); Console.log(properties); YamlMapFactoryBean yamlMapFactoryBean = new YamlMapFactoryBean(); // yamlPropertiesFactoryBean.setResources(new FileUrlResource("E:\\IDEA_Project\\Prosonal\\spirngboot226\\src\\main\\resources\\test.yml")); yamlMapFactoryBean.setResources(new ClassPathResource("test.yml"),new ClassPathResource("test2.yml")); Map<String, Object> map = yamlMapFactoryBean.getObject(); Console.log(map); } }