Sony
Sony

Reputation: 7196

Spring boot not picking value from environment variable in windows

I have declared db url, db user and db password in application.properties like this

spring.datasource.url=${SPRING_DB_URL}
spring.datasource.username=${SPRING_DB_USER}
spring.datasource.password=${SPRING_DB_PASS}

This works in Ubuntu 16.04 but it is not working in windows 7, and the web application is not starting and in logs, it is showing,

Driver com.microsoft.sqlserver.jdbc.SqlServerDriver claims not to accept jdbcurl, ${SPRING_DB_URL}

I tried setting the environment variable with key like this, spring_datasource_url but that too is not working.

the app is build as war file

Why this works in Ubuntu but not in Windows 7?

Upvotes: 2

Views: 3198

Answers (1)

Ryuzaki L
Ryuzaki L

Reputation: 40048

From Externalized Configuration So use the key in upper case letters with combination of underscore if needed

If you use environment variables rather than system properties, most operating systems disallow period-separated key names, but you can use underscores instead (for example, SPRING_CONFIG_NAME instead of spring.config.name).

Upvotes: 1

Related Questions