spring boot external config

后端 未结 5 1157
清歌不尽
清歌不尽 2020-12-30 04:59

I am trying to load an external properties file into my spring boot app. initially I used @PropertySource in the config class. but now I want to remove this annotation so th

5条回答
  •  醉话见心
    2020-12-30 05:44

    In command line you should use below property to mention an additional boot configuration file:

    --spring.config.location="file:/path/to/application.properties"
    

    An alternative would be:

    -Dspring.config.location="file:/path/to/application.properties"
    

    Note that characters are lower case and the word separator is a period ..

    Otherwise you can use an environment variable with key you used already:

    • In a *nix system:

      export SPRING_CONFIG_NAME=file:/path/to/application.properties
      
    • In Windows OS:

      set SPRING_CONFIG_NAME=file:/path/to/application.properties
      

提交回复
热议问题