My connection config:
@Configuration @EnableR2dbcRepositories public class DatabaseConfiguration extends AbstractR2dbcConfiguration { @Bean public PostgresqlConnectionFactory connectionFactory() { return new PostgresqlConnectionFactory(PostgresqlConnectionConfiguration.builder() .host("r2dbc:postgresql://mydb.alfa") .port(5432) .username("admin") .database("postgres") .password(password) .build() ); } } My repository:
public interface ReactiveOdometerRepository extends ReactiveCrudRepository<OdometerEntity, String> { Flux<OdometerEntity> findTop1By(String name); } My entity:
@Setter public class OdometerEntity { @Getter @Id private String name; @Getter private int value; } When I try querying the DB, it fails:
@PostMapping(value = "/query", produces = MediaType.APPLICATION_JSON_VALUE) public int get(@RequestBody RequestObject request) { return odometerRepository.findTop1ByName(request.getName()).getValue(); Error:
io.r2dbc.postgresql.PostgresqlConnectionFactory$PostgresConnectionException: Cannot connect to r2dbc:postgresql://mydb.alfa/<unresolved>:5432 Not sure what the unresolved is doing in there.
How do I fix this error? thanks
hostproperty to contain the name of the host, not the full URL. So I would expecthost("mydb.alfa").