Reputation: 3
I'm building a fully reactive microservice and using the R2DBC way of connecting to the database.
I noticed that in build.gradle I have two following two drivers:
runtimeOnly 'org.postgresql:postgresql'
runtimeOnly 'org.postgresql:r2dbc-postgresql'
After a short search I managed to find out that the first dependency is the JDBC driver and the second is the R2DBC driver. When I decided to comment out the first dependency and run my tests, I started getting errors related to picking up the PostgreSQLContainer. Here is what his setup looks like at this stage:
@Container
@ServiceConnection
public static PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:16.2")
.withInitScript("database/db-init.sql");
When I uncomment the JDBC postgres driver my tests start running and passing as before.
I'm using the @ServiceConnection annotation as a replacement for DynamicPropertySource because the Spring Boot version I'm using is 3.2.5. I think it's trying to create a JDBC connection between the application and the PostgreSQL container, and I don't want that. How can I make the @ServiceConnection annotation make an R2DBC connection?
I found on the internet that the @R2dbcServiceConnection annotation exists, but when I try to use it, my program can't find it and I can't import it.
Upvotes: 0
Views: 103