title: Can't save user to mongodb in Spring 5 WebFlux
body: <p>I try to save User to Mongo database in reactive style with Spring WebFlux, but data isn't saved, so I have Java 8, Spring 5 and mongodb.</p>
  
  <p>This is my config:</p>
  
  <p>My entity:</p>
  
  <pre><code>@Document
  public class User {
      @Id
      private String id;
      private String username;
      private String password;
  }
  </code></pre>
  
  <p>My repository:</p>
  
  <pre><code>public interface UserRepository extends ReactiveMongoRepository&lt;User, String&gt; {
  }
  </code></pre>
  
  <p>My web config:</p>
  
  <pre><code>@Configuration
  @EnableWebFlux
  public class WebConfig {
  
      @Autowired
      private UserRepository userRepository;
  
      @Bean
      public RouterFunction userRoutes() {
          return route(POST("/admin/users").and(accept(APPLICATION_JSON)),
                          request -&gt; {
                              Mono&lt;User&gt; user = request.bodyToMono(User.class);
                              Mono&lt;User&gt; userMono = user.doOnNext(userRepository::save)
                              return ServerResponse.().body(userMono, User.class);
                          });
      }
  }
  </code></pre>
  
  <p>May be I have to manual execute subscribe after save to repository, but I havn't found such info in spring reference?</p>
  
  <p><strong>UPD:</strong>
  But if I extract from request User and pass it to userRepository and return result I have got a successful result to save data to mongo. But I am not sure that it is a good approach:</p>
  
  <pre><code>@Bean
  public RouterFunction userRoutes() {
      return route(POST("/admin/users").and(accept(APPLICATION_JSON)),
                      request -&gt; {
                          User user = request.bodyToMono(User.class).block();
                          Mono&lt;User&gt; userMono = userRepository.save(user);
                          return ServerResponse.ok().body(userMono, User.class);
                      });
  }
  </code></pre>