application.properties

Spring-Boot multi module unable to read properties file from another module

徘徊边缘 提交于 2019-12-01 08:54:34
I have searched High and low and still I am unable to find a simple answer to this very annoying problem, I have followed this great guide: JWT with multi service app Everything works great but in the end of the guide we are suggested to create a config-service(module) , which I have done. The problem is that I am unable to override the default configuration of JwtConfig class The project structure is as follows: -config-service | JwtConfig.java \ | resources \ | jwtConfig.properties -other-service (add dependency in the pom file of the config-service) | someOtherclass.java (import the

Spring Boot: @Value returns always null

我与影子孤独终老i 提交于 2019-11-30 03:18:36
问题 I would like to use a value from application.properties file in order to pass it in the method in another class. The problem is that the value returns always NULL . What could be the problem? Thanks in advance. application.properties filesystem.directory=temp FileSystem.java @Value("${filesystem.directory}") private static String directory; 回答1: You can't use @Value on static variables. You'll have to either mark it as non static or have a look here at a way to inject values into static