JUnit run configurations append spring.datasource parameters to java command
I'm working on a Spring Boot project including JDBC and Spock Framework tests.
Inside both production and test `application.yml` file I have configured Spring's DataSource in the following way:
spring:
datasource:
url: jdbc:postgresql://localhost:5432/dbname
username: dbuser
password: changeme
After writing the first JDBC-based test, I tried running it using the 'play' symbol displayed next to a method declaration. This, as expected, created a JUnit run configuration. However, executing this configuration runs this command:
/home/max/.jdks/temurin-17.0.2/bin/java -ea -Dspring.datasource.username=postgres -Dspring.datasource.password=postgres <censored>
Which in turn causes test unit to fail due to datasource authentication error. I have checked the run configuration for environment variables or CLI argument that might cause this behavior, but found nothing. The only VM options are `-ea` and user's environment variables is empty.
I have a single PostgreSQL instance configured in this project, however its credentials are different and actually correct.
I've searched through `.idea` directory for files containing `postgres` substring and did not find anything subjectively relevant.
What else might possibly cause this behavior?
Please sign in to leave a comment.
Which version of IDE do you use? Can you check if your yml file is configured as configuration file in File | Project Structure | Facets | Spring?
Yes, the configuration file is added.
Is it possible for you to share the project e.g. by creating a ticket here https://youtrack.jetbrains.com/issues/IDEA and attaching a zip or a VCS link? Or through this link https://uploads.jetbrains.com/ and then share the Upload ID