英文:
Load application.properties when the config server is not resolved
问题
我的项目有一个bootstrap.yaml和一个配置服务器,它们提供了适当的配置文件。一切都运行得很好,但我还需要完成一些其他的任务,比如持续集成和持续交付。
我的问题是,因为Jenkins机器不允许解析外部域名,它试图在没有配置文件的情况下编译和运行Spring Boot应用程序。
所以我的问题是:
- 在配置服务器未解析时,是否有一种加载application.properties的方法?
英文:
My project has a bootstrap.yaml and a config server that deliver its appropriate profile. Everything is working great but I have to accomplish some others task like CI and CD.
My problem comes because the Jenkins machine is not allowed to resolved external domains and try to compile and run the Spring boot app without an a profile.
So my question is:
- Is there a way to load application.properties when the config server
is not resolved?
答案1
得分: 1
是的,有一种基于Spring Boot加载PropertySource
顺序的自然方式。
您可以在application.properties
中包含要应用的属性。
如果配置服务器不可用 - 将使用application.properties
中的属性。如果配置服务器可用 - 您将从那里接收属性。
您还可能希望使用环境变量SPRING_CLOUD_CONFIG_ENABLED=false
禁用CI的配置服务器连接。
英文:
Yes, there is a natural way based on the order in which Spring Boot loads PropertySource
s.
You can include properties you want to be applied in application.properties
.
In case config server is not available - properties from application.properties
will be used. If config server is available - you'll receive properties from there.
You might also want to disable config server connectivity for your CI using environment variable SPRING_CLOUD_CONFIG_ENABLED=false
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论