Issue
I wrote an e mail program. But I had to change the some configs, so in my project I need to know how to read from yaml for my loginUrl
my code below;
userNotificationEmail.setIsActive("F");
userNotificationEmailRepository.save(userNotificationEmail);
activationResultType.setResultCode(ActivationResultCode.SUCCESSFUL);
activationResultType.setUser(userMapper.fromUser(userEntity));
activationResultType.setLoginUrl(loginUrl);
return activationResultType;
Solution
If your key is loginUrl
(inside your yaml file), you can inject its value with the @Value
annotation, inside a Spring component.
@Value("${loginUrl}")
private String loginUrl;
If it's a second level property, the path is @Value("${yourFirstKey.loginUrl}")
.
More documentation about reading YAML files with Spring Boot.
Answered By - Thoomas
Answer Checked By - Senaida (JavaFixing Volunteer)