@Container static PostgreSQLContainer postgres = new PostgreSQLContainer<>("postgres:15.7-alpine") .withDatabaseName("testdb") .withUsername("test") .withPassword("test") .withReuse(true); static { postgres.start(); } @DynamicPropertySource static void setDatasourceProperties(DynamicPropertyRegistry registry) { registry.add("spring.datasource.url", postgres::getJdbcUrl); registry.add("spring.datasource.username", postgres::getUsername); registry.add("spring.datasource.password", postgres::getPassword); }