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?

0

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?

0

Yes, the configuration file is added.

IntelliJ IDEA 2022.1 (Ultimate Edition)
Build #IU-221.5080.210, built on April 12, 2022
Licensed to
Subscription is active until
Runtime version: 11.0.14.1+1-b2043.25 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.17.5-arch1-1
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 16
Registry:
    scala.erase.compiler.process.jdk.once=false

Non-Bundled Plugins:
    some.awesome (1.14)
    net.vektah.codeglance (1.5.4)
    net.sf.opk.avro-schema-support (213.0.1)
    com.wakatime.intellij.plugin (13.1.14)
    com.samdark.intellij-visual-studio-code-dark-plus (2.5)
    com.pinkfloyded.idea-file-path-autocomplete.idea-file-path-autocomplete (0.4.1)
    com.jetbrains.plugins.ini4idea (221.5080.126)
    com.jetbrains.ChooseRuntime (1.2)
    com.daynight.plugin (1.2.7)
    PlantUML integration (5.12.0)
    Key Promoter X (2022.1.1)
    IdeaVIM (1.10.2)
    zielu.gittoolbox (212.8.9)
    mobi.hsz.idea.gitignore (4.4.0)
    Spock Framework Enhancements (0.12)
    org.intellij.scala (2022.1.13)
    Pythonid (221.5080.212)
    com.y4kstudios.pytestimp (0.5.5)
    com.koxudaxi.pydantic (0.3.12)
    aws.toolkit (1.42-221)
    ru.adelf.idea.dotenv (2022.1)
    dev.eltonsandre.intellij.spring.assistant.plugin (1.5.0)

Kotlin: 221-1.6.20-release-285-IJ5080.210
Current Desktop: Undefined
0

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

0

请先登录再写评论。