java Docker compose和Spring引导配置服务器
我有一个工作的SpringBootWeb应用程序,它从SpringBootConfigServer获取其配置属性。我的应用程序有3个环境-dev、qa和prod。在我的资源文件夹中,我有3个文件bootstrap-dev.properties、bootstarp-qa。属性和bootstrap-prod.properties。下面显示了一个示例引导文件
spring.application.name=MyApp
spring.cloud.config.uri=http://my.config.server
spring.cloud.config.label=feature-branch-101
spring.output.ansi.enabled=ALWAYS
spring.profiles.active=dev
我需要在docker compose文件中放入哪些内容,这些文件可以从spring boot配置服务器读取配置并支持3种不同的环境。有人有样品吗
# 1 楼答案
这就是JHispter的人是如何做到的(见下面的文件)
我认为诀窍在于
app.yml
文件,您可以在该文件中设置要为应用程序的环境运行的配置文件。像这样:因此,从那时起,
application.yml
和bootstrap.yml
知道要加载到SpringBoot中的环境属性Dockerfile
应用程序。yml
mysql。yml(如果需要)
引导。yml