@ConfigurationProperties(prefix ="spring.r2dbc")publicclassR2dbcProperties { /** * Database name. Set if no name is specified in the url. Default to "testdb" when * using an embedded database. */privateString name; /** * Whether to generate a random database name. Ignore any configured name when * enabled. */privateboolean generateUniqueName; /** * R2DBC URL of the database. database name, username, password and pooling options * specified in the url take precedence over individual options. */privateString url; /** * Login username of the database. Set if no username is specified in the url. */privateString username; /** * Login password of the database. Set if no password is specified in the url. */privateString password;
@Data@AllArgsConstructorpublicclassUsers { @IdprivateInteger id;privateString firstname;privateString lastname;booleanhasId() {return id !=null; }}
再看一下我们创建的UserDao:
publicinterfaceUsersDaoextendsReactiveCrudRepository<Users,Long> { @Query("select id, firstname, lastname from users c where c.lastname = :lastname")Flux<Users> findByLastname(String lastname);}