Spring boot external application.properties

前端 未结 5 683
长发绾君心
长发绾君心 2020-12-15 22:20

I am developing a spring boot application

I want to override some properties in src/main/resources/application.properties with an external file (e.g.

5条回答
  •  天命终不由人
    2020-12-15 22:53

    I had the same requirement like yours( war package instead of a fat jar) and I manged to externalize the configuration file: In my main class I made this configuration:

    @SpringBootApplication
    @PropertySource("file:D:\\Projets\\XXXXX\\Config\\application.properties")
    public class WyApplication extends SpringBootServletInitializer {
    
        public static void main(String[] args) {
            SpringApplication.run(WyApplication.class, args);
        }
    
    }   
    

    Hope this will help you. Good luck.

提交回复
热议问题