spring-bootconfigurationenvironment-variables

Spring Boot: configuring properties with dash/hyphen using environment variables


One of my favorite Spring Boot features is the ability to configure most things using the UNIX environment variables. Now I'm struggling with ActiveMQ broker config.

To set the broker URL I have to specify spring.activemq.broker-url. Rewritten in environment terms this would be SPRING_ACTIVEMQ_BROKER-URL which is working from Eclipse, but not possible to be defined as environment variable in any UNIX shell.

Using env is not an option due to other restrictions.

Is there something I missed or do I have to remap those "dashed" properties in an own @PropertiesConfiguration?

Any hints?


Solution

  • Take a look at the documentation on relaxed binding.

    The key in your application.properties or application.yml file will be spring.activemq.broker-url and your env var will be SPRING_ACTIVEMQ_BROKER_URL.