A few months ago I had written about how one can setup a PostgreSQL database in a docker container during the Maven testing phase (part 1 and part 2). Today, I wanted to iterate on this topic using Testcontainers. Unfortunately, before I could get to that I ran into issues with the original project. For some reason I was now getting the following error:
Caused by: java.lang.RuntimeException: Driver org.postgresql.Driver claims to not accept jdbcUrl, jdbc:postgresql://localhost:${it-database.port}/docker_db_testing_tests
Maven did not replace the variable it-database
in the integration
test application.properties
file. The question is: "why now"? It
has worked before. Now, one thing that I changed is that this time I
was using Linux instead of Windows. Either way, the fix was simple,
although not obvious. It seems to be an issue with the Maven Failsafe
plugin.
Not working:
<configuration>
<environmentVariables>
<it-database.port>${it-database.port}</it-database.port>
</environmentVariables>
</configuration>
Working:
<configuration>
<systemPropertyVariables>
<it-database.port>${it-database.port}</it-database.port>
</systemPropertyVariables>
</configuration>