0

I am trying to get properties file value loaded in my java Application class, but it is not loading, as Sysout is printing null. Anything I am missing for my code. When I am starting the Spring container, I can see the values of the properties file loaded in the log as below :

015-12-24 22:36:08.313  INFO 22224 --- [           main] com.ge.predix.solsvc.boot.Application    : propertySource=applicationConfig: [file:./config/application.properties] values={logging.level.org.springframework=INFO, server.port=9092, logging.level.root=INFO}class=class org.springframework.core.env.PropertiesPropertySource
2015-12-24 22:36:08.313  INFO 22224 --- [           main] com.ge.predix.solsvc.boot.Application    : propertySource=class path resource [application-default.properties] values={**predix.oauth.clientId=admin:cargo_beta**, spring.profiles.active=local, predix.oauth.restHost=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}class=class org.springframework.core.io.support.ResourcePropertySource

        @PropertySources({
            @PropertySource("classpath:application-default.properties") 
        })
        @SpringBootApplication
        @Configuration
        public class Application
        {
            private static final Logger log = LoggerFactory.getLogger(Application.class);



            @Value("${predix.oauth.clientId}")   
            private static String loc;



public static void main(String[] args)
        {
            SpringApplication springApplication = new SpringApplication(Application.class);
            ApplicationContext ctx = springApplication.run(args); 

System.out.println("#############################################" +loc);

}
} 
Robert Moskal
  • 21,737
  • 8
  • 62
  • 86
sromit
  • 900
  • 3
  • 16
  • 43

1 Answers1

0

Short answer is that spring won't inject a value into a static member: Spring: How to inject a value to static field?

Community
  • 1
  • 1
Robert Moskal
  • 21,737
  • 8
  • 62
  • 86