Skip to content

Support externalized configuration for launching with bazel run #135

Closed
@plaird

Description

@plaird

It is a useful feature for Spring Boot to load external configuration files (files not included in the exectuable jar) at runtime. This allows you to override some properties in production for example. You can do this via command line arguments, but the property file approach is common.

https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.external-config.files

Spring Boot will automatically find and load application.properties and application.yaml files from the following locations when your application starts:

  • The current directory
  • The /config subdirectory in the current directory
  • Immediate child directories of the /config subdirectory

This works if you launch the rules_spring built executable jar with java -jar:

java -jar example.jar

But we don't have a great way to do this when launching the application with bazel run. As a workaround the developer can invoke bazel run like this:

bazel run //examples/demoapp -- --spring.config.location=/tmp/demoapp/config/

but it feels like we should automatically honor package level files like:

  • //examples/demoapp/application.properties
  • //examples/demoapp/config/application.properties
  • //examples/demoapp/config/secure/application.properties

When working on this, remember to support profile specific prop files: https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.external-config.files.profile-specific

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions