See this: Spring @PropertySource using YAML
I think the 3rd answer has what you're looking for, i.e have a separate POJO to map your yaml values into:
@ConfigurationProperties(path="classpath:/appprops.yml", name="db")
public class DbProperties {
private String url;
private String username;
private String password;
...
}
Then annotate your test class with this:
@EnableConfigurationProperties(DbProperties.class)
public class PropertiesUsingService {
@Autowired private DbProperties dbProperties;
}