0

In SpringBoot we have @ConfigurationProperties annotation which could be used to map env properties to Spring bean. Do we have similar construct in pure Spring application?

We have non SpringBoot application (WAR deployment), where we want to read properties in SpringBoot style.

We have tried in including

  <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-autoconfigure</artifactId>
        </dependency>

and use @EnableConfigurationProperties but that is not working

 @PropertySource("classpath:test.yaml")
    @EnableConfigurationProperties(value = {TestProperties.class})
    public static class Config {

    }
pmehra
  • 11
  • 3
  • Have you looked at [this question](https://stackoverflow.com/questions/40835785/inject-application-properties-without-spring) ? – Arnaud Claudel Aug 27 '19 at 19:18
  • Thanks, but is it possible to do this in Spring? I like Environment abstraction as it provides possibility to override using -D variable during startup. – pmehra Aug 30 '19 at 14:09
  • You can do this using the proposed solution. Simply use an system property to retrieve the path of the config file – Arnaud Claudel Aug 30 '19 at 17:01

0 Answers0