Spring boot external application.properties

前端 未结 5 667
长发绾君心
长发绾君心 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:55

    Notes

    1) Tomcat allows you to define context parameters 2) Spring Boot will read the properties defined in Tomcat context parameters as if you are defining them as -Dsomething=some_value

    Options

    Option 1: Hence a possible way is for you to define spring.config.location at the Tomcat context paramter:

    
        
    
    

    Option 2: define a system property at the Tomcat's setenv.sh file

    Dspring.config.location=/path/to/application.properties
    

    Option 3: define an environment variable: SPRING_CONFIG_LOCATION

提交回复
热议问题