@RestController
Class MyController{
@Value("${welcome}")
private String welcome;
@RequestMapping("/greet")
public String greetHim(){
return welcome;
}
}
application.properties:
welcome=welcomeEla
The above code is throwing illegal argument exception and saying could not resolve placeholder 'welcome' in value "${welcome}"
If I give a space between '$' and '{' it is not throwing any exception but it is fetching null value.
Also I tried with environment variable as autowired with @PropertySource("application.properties") over the Class it was also fetching null value (env.getProperty("welcome"))
Can anybody help me in this? Thanks in advance