-1

I use this configure

application.properties

user.name.auth=s-SGH-S0007
 @Value("${user.name.auth}")
    private String userNameAuth;

when I try to get a value from a given property, then I get an error.

nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'user.name.auth' in value "${user.name.auth}"

how can I get around this error (without using yaml)?

eis
  • 51,991
  • 13
  • 150
  • 199
skyho
  • 1,438
  • 2
  • 20
  • 47
  • 2
    This indicates that the value isn't loaded from `application.properties`. This has nothing to do with "special" characters in the value. – M. Deinum Feb 08 '21 at 14:10
  • You're right. I have seen. – skyho Feb 08 '21 at 14:31
  • there isn't enough information in this question to give an answer, but as a guess: are you using maven but not inheriting from spring boot starter parent? – eis Feb 08 '21 at 14:42
  • Other possible causes: https://stackoverflow.com/questions/48158249/spring-boot-could-not-resolve-placeholder-in-string – eis Feb 08 '21 at 14:43

1 Answers1

0

In my case, since I was running an integration test, and the values for the properties were only specified in the application. properties of the application, so I got an error. If the entry point is in the test loop, then there it was necessary to define the desired properties in application.properties as well.

skyho
  • 1,438
  • 2
  • 20
  • 47