Skip to content
Advertisement

Auditing (@CreatedDate) does not work for WebFlux Spring Boot with reactive MongoDB

Does WebFlux Spring Boot with reactive MongoDB supports Auditing? I tried to use @CreatedDate and it did not work for me. Here is my configuration:

JavaScript

Here is my document class

JavaScript

Here is Message repository

JavaScript

When I save message messageRepository.save(message) I always have createdDate=null

Do I miss something or Auditing does not work with reactive MongoDB?

Advertisement

Answer

I resolved the issue by using @EnableReactiveMongoAuditing, not @EnableMongoAuditing as I initially did. Apparently the reactive annotation should be used with ReactiveMongoRepositories. So the correct configuration is the following:

JavaScript

So after saving a message the corresponding createdDate is added automatically:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement