0

I define my custom yml file(something not named application.yml) on my SpringBoot project.

Here's my code.

@Component
@PropertySource("classpath:/custom.yml")
public class CustomConfig {
  @Value("${test.name}")
  private String testName;
}
//custom.yml
//binding failed set as null
test:
   name: hello

//binding success
test.name: hello

At first, I tried to use @configurationproperties.

But it's not working, and then I tried to test on @Value.

Now I found that it fail binding when yml file is in hierarchy structure.

Any ideas to solve this problem?

I want to set my custom,yml in hierarchy structure.(including list data) Please help me!

Chloe
  • 141
  • 2
  • 13
  • The issue seems to be that PropertySource does not cope with YAML. There are some clues on how to get there in this other question: https://stackoverflow.com/questions/21271468/spring-propertysource-using-yaml – β.εηοιτ.βε Jun 04 '22 at 22:15

0 Answers0