Update to core r2dbc support
This commit adapts the auto-configuration for the new core r2dbc support in Spring Framework and provides auto-configuration for R2dbcEntityOperations. Closes gh-22708
This commit is contained in:
@@ -1972,7 +1972,7 @@ You can tune that behavior by setting `spring.datasource.continue-on-error`.
|
||||
=== Initialize a Database Using R2DBC
|
||||
If you are using R2DBC, the regular `DataSource` auto-configuration backs off so none of the options described above can be used.
|
||||
|
||||
If you are using Spring Data R2DBC, you can initialize the database on startup using SQL scripts as shown in the following example:
|
||||
You can initialize the database on startup using SQL scripts as shown in the following example:
|
||||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
|
||||
@@ -4215,7 +4215,7 @@ If you want to make sure that each context has a separate embedded database, you
|
||||
|
||||
[[boot-features-r2dbc-using-database-client]]
|
||||
==== Using DatabaseClient
|
||||
Spring Data's `DatabaseClient` class is auto-configured, and you can `@Autowire` it directly into your own beans, as shown in the following example:
|
||||
A `DatabaseClient` bean is auto-configured, and you can `@Autowire` it directly into your own beans, as shown in the following example:
|
||||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.DefaultResourceLoader;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.data.r2dbc.connectionfactory.init.ResourceDatabasePopulator;
|
||||
import org.springframework.r2dbc.connection.init.ResourceDatabasePopulator;
|
||||
|
||||
/**
|
||||
* Example configuration for initializing a database using R2DBC.
|
||||
@@ -41,7 +41,7 @@ public class R2dbcDatabaseInitializationExample {
|
||||
ResourceLoader resourceLoader = new DefaultResourceLoader();
|
||||
Resource[] scripts = new Resource[] { resourceLoader.getResource("classpath:schema.sql"),
|
||||
resourceLoader.getResource("classpath:data.sql") };
|
||||
new ResourceDatabasePopulator(scripts).execute(connectionFactory).block();
|
||||
new ResourceDatabasePopulator(scripts).populate(connectionFactory).block();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user