|
17 | 17 |
|
18 | 18 | import io.r2dbc.postgresql.PostgresqlConnectionConfiguration; |
19 | 19 | import io.r2dbc.postgresql.PostgresqlConnectionFactory; |
20 | | -import io.r2dbc.spi.ConnectionFactory; |
| 20 | + |
| 21 | +import javax.annotation.PreDestroy; |
21 | 22 |
|
22 | 23 | import org.springframework.context.annotation.Bean; |
23 | 24 | import org.springframework.context.annotation.Configuration; |
24 | | -import org.springframework.data.r2dbc.function.DatabaseClient; |
25 | | -import org.springframework.data.r2dbc.repository.support.R2dbcRepositoryFactory; |
26 | | -import org.springframework.data.relational.core.mapping.RelationalMappingContext; |
| 25 | +import org.springframework.data.r2dbc.repository.config.AbstractR2dbcConfiguration; |
| 26 | +import org.springframework.data.r2dbc.repository.config.EnableR2dbcRepositories; |
27 | 27 | import org.testcontainers.containers.PostgreSQLContainer; |
28 | 28 |
|
29 | | -import javax.annotation.PreDestroy; |
30 | | - |
31 | 29 | /** |
32 | 30 | * @author Oliver Gierke |
| 31 | + * @author Mark Paluch |
33 | 32 | */ |
34 | 33 | @Configuration |
35 | | -class InfrastructureConfiguration { |
| 34 | +@EnableR2dbcRepositories |
| 35 | +class InfrastructureConfiguration extends AbstractR2dbcConfiguration { |
36 | 36 |
|
37 | 37 | private PostgreSQLContainer postgres = new PostgreSQLContainer(); |
38 | 38 |
|
39 | 39 | @Bean |
40 | | - CustomerRepository customerRepository(R2dbcRepositoryFactory factory) { |
41 | | - return factory.getRepository(CustomerRepository.class); |
42 | | - } |
43 | | - |
44 | | - @Bean |
45 | | - R2dbcRepositoryFactory repositoryFactory(DatabaseClient client) { |
46 | | - |
47 | | - RelationalMappingContext context = new RelationalMappingContext(); |
48 | | - context.afterPropertiesSet(); |
49 | | - |
50 | | - return new R2dbcRepositoryFactory(client, context); |
51 | | - } |
52 | | - |
53 | | - @Bean |
54 | | - DatabaseClient databaseClient(ConnectionFactory factory) { |
55 | | - |
56 | | - return DatabaseClient.builder() // |
57 | | - .connectionFactory(factory) // |
58 | | - .build(); |
59 | | - } |
60 | | - |
61 | | - @Bean |
62 | | - PostgresqlConnectionFactory connectionFactory() { |
63 | | - |
| 40 | + @Override |
| 41 | + public PostgresqlConnectionFactory connectionFactory() { |
64 | 42 |
|
65 | 43 | postgres.start(); |
66 | 44 |
|
|
0 commit comments