在spring boot中将属性放在application.yml或bootstrap.yml上有什么区别?在logging.config的情况下,应用程序的工作方式不同。
发布于 2018-07-22 09:17:15
这里只有我的2分钱..
使用Bootstrap.yml或Bootstrap.properties从Spring Cloud Server获取配置。
例如,在我的Bootstrap.properties文件中,我有以下配置
spring.application.name=Calculation-service
spring.cloud.config.uri=http://localhost:8888
在启动应用程序时,它尝试通过连接到http://localhost:8888来获取服务的配置,并查看Spring Cloud Config服务器中存在的计算服务属性
您可以在Calcuation Service启动时从日志中进行验证
INFO 10988 --- [ restartedMain] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888
发布于 2020-06-15 20:13:08
Bootstrap.yml是启动spring boot应用程序时加载的第一个文件,application.property是在应用程序启动时加载的。所以,你保留,可能是你的配置服务器的凭证等,在bootstrap.yml中,这是在加载应用程序时需要的,然后在application.properties中,你可能是数据库的网址等。
发布于 2021-07-28 05:44:54
当您使用Spring Cloud,并且您的应用程序配置存储在远程配置服务器(例如,Spring Cloud Config Server)上时,可以使用bootstrap.yml。在application.yml之前加载bootstrap.yml
https://stackoverflow.com/questions/32997352
复制相似问题