1. Background introduction
There are three Springboot Maven projects A, B, and C, that is, three jar packages. Project A writes the underlying database mapper, which is referenced by B and C.
For convenience, the database configuration wants to be written directly in the yaml file in A, so that there is no need to write database connection information in the yaml files of B and C projects, but the test found that when project B was started, A was not read The configuration information in the project yaml file.
2. The cause of the problem
The yaml files of the three projects of A/B/C are all under the resource files of their own projects. When B refers to A, it is equivalent to two identical yaml files in the same directory. At this time, B’s yaml files will be blocked Delete the yaml file of the A file.
⚠️Note: This is the entire file shielding, not that the same configuration is shielded
Three, the solution
3.1 Only keep one yaml file
This method is only applicable when all the configuration information of the yaml files in the A, B, and C projects are the same, but the individual configuration information values are different
3.2 Place the yaml file in A in the config directory
The following picture is from the springBoot official website: