Multiple application.yml not merged in Spring Boot

情到浓时终转凉″ 提交于 2021-01-27 10:40:54

问题


I have a module for database communication(my-db-lib), and which is imported to spring boot based web application module(my-web-app)

I want to set configuration about db in my-db-lib, and set about web app in my-web-app

When I use yml file,

  1. application.yml in my-db-lib db: url: localhost
  2. application.yml in my-web-app app: message: hello

When my-web-app runs, it can read only app.message not db.url

It seems that yml files are just replaced with one which has highest priority (when not use profiles) Is it right? How can I achieve purpose?

Thanks, And sorry for my poor English :D


回答1:


The application.yml in child module will be override by application.yml in parent module.

You can use this:

  1. application-my-db-lib.yml for module my-db-lib
  2. application.yml for module my-web-app


来源:https://stackoverflow.com/questions/50667281/multiple-application-yml-not-merged-in-spring-boot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!