Trying out R2DBC
Before we can fetch any data, we have to load some data. While this is normally something our DBA deals with, for this chapter we’ll just have to do it ourselves. To do that, we need to create a Spring component that will automatically kick off once our application is up. Create a new class named Startup
and add the following code:
@Configuration public class Startup { @Bean CommandLineRunner initDatabase(R2dbcEntityTemplate template) { return args -> { // Coming soon! } } }
This code can be described as follows:
@Configuration
: Spring’s annotation to flag this class as a collection of bean definitions, needed to autoconfigure our application@Bean
: Spring’s annotation to turn this method into a Spring bean, added to the application context...