I'm following this example https://github.com/hantsy/spring-reactive-sample/blob/master/boot-exception-handler/src/main/java/com/example/demo/DemoApplication.java ...which works -- sets the createDate MongoDB field on creation. The version there is 2.1.6.RELEASE. However, when I upgrade this to 2.4.2, createDate is no longer set. There are no warnings, it seems just to have stopped working.
The model class is:
@Document
@Data
@ToString
@Builder
@NoArgsConstructor
@AllArgsConstructor
class Post {
@Id
private String id;
private String title;
private String content;
@CreatedDate
private LocalDateTime createdDate;
@Version
private Integer version;
}
Also, MongoDB auditing is set:
@SpringBootApplication
@EnableMongoAuditing
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
Is this is a known issue by any chance? I couldn't find any migration notes on this. How to enable auditing in the latest Spring Boot version?
Update:
Looks like the latest version where it worked is with spring-boot-starter-parent 2.3.7.RELEASE. Stops working when switch this to 2.4.0.