Does application.yaml refer to the contents of other configuration files?

configuration file of how application.yaml in SpringBoot is referenced.

spring:
    datasource:
        druid:
            url: ${jdbc.url}
            username: ${jdbc.username}

where jdbc.url , jdbc.username is in another file jdbc.yaml .

how is it implemented?

Mar.07,2021

you can use maven's profiles. Placeholder replacement is performed during build based on the profiles configuration in maven.


you can name the jdbc.yaml file application-jdbc.yaml .
set the jvm parameter -Dspring.profiles.active=jdbc when starting spring-boot , so that spring-boot will load the application.yaml configuration file and the corresponding profile configuration file.

multiple profile are separated by commas

$ java -Dspring.profiles.active=jdbc,jdbc2 -jar [xxx].jar
Menu