0

I have the follow YAML file

git.username: myusername
git.password: mypassword

And in my Java Source file, I have the following annotation

@Value("${git.username}")
private String username;
@Value("${git.password}")
private String password;

Everything works fine till this point. However, it is not able to retrieve the value when I changed the format of the YAML to the following.

git:
  username: myusername
  password: mypassword

How should I reference the yaml value in this format? @Value(???)

Mox
  • 2,355
  • 2
  • 26
  • 42
  • look here: https://www.baeldung.com/spring-yaml – Marc Stroebel Jul 23 '20 at 09:37
  • Where is your yaml file located? Is any other property working or just git ones don't? What type of indentation are you using? – tec Jul 23 '20 at 09:37
  • The linked duplicate provides many suggestions, i.e. indentation, duplicate keys, etc. Your attempt looks broadly correct, you shouldn't have to change the annotation – Michael Jul 23 '20 at 09:39
  • @tec I have not tried the rest, but just the git one is not working. I mean it works in the old format, just not in the new format which puzzles me. – Mox Jul 23 '20 at 09:39
  • @Michael that means it is possibly the indentation? – Mox Jul 23 '20 at 09:40

0 Answers0