0

I have already set environment variables on windows, and actually when I echo them =, I can see their details, however, when I ran tests they seem not to see the environment variables. I have seen similar questions but they weren't helpful. Like this one, this etc but no luck.

this my application-test.properties file

## PostgreSQL
spring.datasource.url=jdbc:postgresql://${DB_HOST}:${DB_PORT}/users_regsitration_test
spring.datasource.username= ${DB_USERNAME}
spring.datasource.password= ${DB_PASSWORD}
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true

then, this is the exception am getting :

users_regsitration_test
    at com.zaxxer.hikari.util.DriverDataSource.<init>(DriverDataSource.java:108)
    at com.zaxxer.hikari.pool.PoolBase.initializeDataSource(PoolBase.java:336)
    at com.zaxxer.hikari.pool.PoolBase.<init>(PoolBase.java:109)
    at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:108)
    at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
    at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:157)
    at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:115)
    at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:78)
    at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:319)
    at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:356)
Idris Stack
  • 546
  • 1
  • 14
  • 36

1 Answers1

1

If you are running it within IDE, then you need to set those variables in "Run Configuration".

I am assuming that you are using either IntelliJ or eclipse, this can be configured as,

  1. Eclipse: Go to your run configuration as, Run -> Run Configuration -> Environment Tab -> Select, this will give you the option to select existing environment variables whichever you want to use for this application.

enter image description here

  1. Same way it can be added to IntelliJ, Run -> Edit Configuration -> Environment Variables:

enter image description here

S_learner
  • 334
  • 2
  • 8