I don't know that there's a good name for this technique, but it's basically what's required when you need to have local database credentials that differ from other developers in a team, and also can't be committed to version control. In React and Vue this feature is called .env.local.

When you need this in Spring, you need to know the following:

  • You can have multiple profiles.
  • But you'll need to end up gitignoring a file pattern at some point anyway.
  • Your 'mainstream' config file is likely stored under your project tree at src/main/resources/application.properties.
  • The default search path for Spring is:
    • file:./config/
    • file:./
    • classpath:/config/
    • classpath:/
  • file:. means the real root of your project, i.e. where your .git directory is, pom.xml, etc.
  • classpath:/ means src/main/resources, broadly speaking.

From this we can reason that the path of least resistance is to add a gitignore rule /config/ (the leading slash is important), and store your custom configuration in config/application.properties in the project root. Of course the more sophisticated way would be to use actual profiles, but this has the benefit of not needing any IDE configuration.