@Value in Springboot returns null

Judging by your package structure, those properties should definitely be loaded. Only possible option is that you have instantiated your Controller class as new Controller() instead of letting spring injecting the class (using @Autowired or constructor injection).


The reason why @Value returns null sometimes is because when you try to use 'application.properties' contents for static variables which is not allowed in spring. Follow this: https://mkyong.com/spring/spring-inject-a-value-into-static-variables/ and it should work fine.


Okay, i solved it with the top answer of this Question. I put the variables and @Values in the signature of the constructor and not as class variables.