SpringBoot project use environment variables in yml, properties file

 

When docker start SpringBoot packaged services, and need to get some parameters from the outside rather than hard-coded in the properties file, complete the requirements in the following two steps:
1. Configure environmental variables in the configuration file

= $ {REDIS_HOST spring.redis.host: 127.0.0.1}
spring.redis.port = 6379
spring.redis.timeout = 30000
above table is REDIS_HOST acquiring system environment variable, if the acquisition is less than the default value 127.0.0.1

2 . incoming environmental parameters at startup docker container

docker run -d --name test2 {mirror name} -e REDIS_HOST = 192.168.0.1
complete program configuration.

Guess you like

Origin www.cnblogs.com/panchanggui/p/12133810.html