Skip to content

Commit

Permalink
add port
Browse files Browse the repository at this point in the history
  • Loading branch information
lankydan committed Feb 17, 2019
1 parent cc381c1 commit e72a14f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion spring-data-r2dbc-wordpress.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>The four properties defined by the <code>PostgresqlConnectionFactory</code> are the bare minimum to get it working. Any less and you will experience exceptions during startup.</p>
<p>I have included the <code>port</code> property here, but if you have not played around with your Postgres configuration then you can rely on the default value of <code>5432</code>.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>The four properties: <code>host</code>, <code>database</code>, <code>username</code> and <code>password</code> defined by the <code>PostgresqlConnectionFactory</code> are the bare minimum to get it working. Any less and you will experience exceptions during startup.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
Expand Down
4 changes: 3 additions & 1 deletion spring-data-r2dbc.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ class DatabaseConfiguration(
```
The first thing to notice here is the extension of `AbstractR2dbcConfiguration`. This class contains a load of Beans that we no longer need to manually create. Implementing `connectionFactory` is the only requirement of the class as it is required to create the `DatabaseClient` Bean. This sort of structure is typical of Spring Data modules so it feels quite familiar when trying out a different one. Furthermore, I'd expect this manual configuration to be removed once auto-configuration is available and be solely driven via the `application.properties`.

The four properties defined by the `PostgresqlConnectionFactory` are the bare minimum to get it working. Any less and you will experience exceptions during startup.
I have included the `port` property here, but if you have not played around with your Postgres configuration then you can rely on the default value of `5432`.

The four properties: `host`, `database`, `username` and `password` defined by the `PostgresqlConnectionFactory` are the bare minimum to get it working. Any less and you will experience exceptions during startup.

Using this configuration, Spring is able to connect to a running Postgres instance.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.springframework.data.r2dbc.repository.config.EnableR2dbcRepositories
@EnableR2dbcRepositories
class DatabaseConfiguration(
@Value("\${spring.data.postgres.host}") private val host: String,
@Value("\${spring.data.postgres.port}") private val port: Int,
@Value("\${spring.data.postgres.database}") private val database: String,
@Value("\${spring.data.postgres.username}") private val username: String,
@Value("\${spring.data.postgres.password}") private val password: String
Expand All @@ -21,6 +22,7 @@ class DatabaseConfiguration(
return PostgresqlConnectionFactory(
PostgresqlConnectionConfiguration.builder()
.host(host)
.port(port)
.database(database)
.username(username)
.password(password).build()
Expand Down

0 comments on commit e72a14f

Please sign in to comment.