Search code examples
springspring-bootspring-ide

Can Spring IDE support editing multiple application.yml files?


I'm using Eclipse Neon with Spring IDE Version 3.8.3.201612191259-RELEASE. Whenever I create an application.yml file under src/main/resources it shows with a Spring embellished icon and allows me to see Spring Boot's configuration (for example see here: https://docs.spring.io/sts/nan/v370/NewAndNoteworthy.html).

For different profiles developers can either use a single YAML file with different sections for each spring.profiles via the --- notation. Developers might also choose to use separate YAML files named with the profile as part of the name (i.e. application-dev.yml) as noted in this link: https://www.mkyong.com/spring-boot/spring-boot-profile-based-properties-and-yaml-example/ .

The functionality provided by the Spring Boot YML Editor is very helpful not only for YAML editing but also because it allows auto-complete for Spring Boot's configuration. Is there a way to associate more than one file to be see by the Spring Boot YML Editor so that I can easily edit files like application-dev.yml in that editor? I know I can right-click on the file and have it open-with Spring Yaml Properties Editor but it would be nice if similar to configuring the Spring Bean support Config Files you could also pick multiple files to be seen as Spring YAML files (or perhaps look for all application-XXX.yml files and associate them to the editor).


Solution

  • The place where to specify file associations for the content type Spring Yaml Properties File can be found in the Eclipse preferences in General > Content Types. Search for the content type Yaml Content Type > Spring Yaml Properties File. In the box below you can add your required file associations.

    As of Eclipse Neon you have to specify all your variants, e.g. application-prod.yml, application-some-profile.yml, ...

    In Eclipse Photon it will be possible to use wildcards, e.g. application-*.yml. See https://www.eclipse.org/eclipse/news/4.8/M2/ for details