我正在关注这个例子https://github.com/hantsy/spring-reactive-sample/blob/master/boot-exception-handler/src/main/java/com/example/demo/DemoApplication.java https://github.com/hantsy/spring-reactive-sample/blob/master/boot-exception-handler/src/main/java/com/example/demo/DemoApplication.java...有效——在创建时设置 createDate MongoDB 字段。那里的版本是2.1.6.RELEASE。但是,当我将其升级到2.4.2,createDate 不再设置。没有任何警告,似乎只是停止工作。
模型类是:
@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;
}
此外,还设置了 MongoDB 审计:
@SpringBootApplication
@EnableMongoAuditing
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
这是一个已知问题吗?我找不到任何关于此的迁移说明。如何在最新的Spring Boot版本中启用审计?
Update:
看起来它工作的最新版本是spring-boot-starter-parent
2.3.7.RELEASE
。当切换到此时停止工作2.4.0
.
使用新的解决了@EnableReactiveMongoAuditing
注释,加上一个像这样的bean
@Bean
public ReactiveAuditorAware<String> auditorProvider() {
return () -> Mono.just("Me");
}
该问题可能与我使用配置应用程序有关@EnableReactiveMongoRepositories
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)