Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to set spring.datasource.driver-class-name via environment variables?

As described in the Spring Boot documentation, configuration can be passed via environment variables. However there are some configuration properties like spring.datasource.driver-class-name which contain hyphens. When setting this in bash you will get an error:

$ export SPRING_DATASOURCE_DRIVER-CLASS-NAME=com.mysql.jdbc.Driver
bash: export: `SPRING_DATASOURCE_DRIVER-CLASS-NAME=com.mysql.jdbc.Driver': not a valid identifier

This is because variables in bash must not contain hyphens. So is it even possible to set Spring configuration properties which contain hyphens via environment variables?

like image 812
britter Avatar asked Dec 18 '22 18:12

britter


1 Answers

Spring Boot provides a relaxed binding. For this reason the environment variable SPRING_DATASOURCE_DRIVER_CLASS_NAME can be used to set the driver class name.

like image 140
britter Avatar answered Dec 21 '22 11:12

britter