我想知道使 DbUnit 与 MySQL 的 JSON(B) 类型列一起使用的最佳方法是什么?我们确实到处都有这样的列,每当我尝试通过 XML 文件提供测试数据时,@DatabaseSetup我都会收到 NoSuchColumnException,这会阻止我对处理 JSON 的实体或存储库进行任何合理的集成测试:
org.dbunit.dataset.NoSuchColumnException: assistant_event.AEV_CONTEXT - (Non-uppercase input column: aev_context) in ColumnNameToIndexes cache map. Note that the map's column names are NOT case sensitive.
Run Code Online (Sandbox Code Playgroud)
我知道这是因为我的AEV_CONTEXT列没有被识别,因为它是一个 JSON 列:
@Type(type = "json")
@Column(name = "aev_context", columnDefinition = "json")
private Context context;
Run Code Online (Sandbox Code Playgroud)
然而,我在尝试解决这个问题时遇到了困难。而且,更奇怪的是,我在这里也找不到这样的解决方法!事实上,我不知道那是属于 Hibernate 还是 DbUnit。
到目前为止真的只有我遇到这个问题吗?任何建议将不胜感激!
哦,如果您想知道,这就是我如何获得 Hibernate 的 JSON 支持:
https://vladmihalcea.com/how-to-map-json-objects-using-generic-hibernate-types/
我有一个 @Scheduled 方法,当我使用嵌入式 tomcat 构建 Spring Boot 应用程序时,该方法运行没有问题。但是当我在 .war 中构建项目并使用 tomcat v8 部署它时,调度程序似乎没有触发。其他功能运行良好,只是这个调度程序没有在我的服务器上触发。
@Component
public class DeleteUser {
@Autowired
private UserService userService;
@Autowired
private UserAuthoritiesService userAuthService;
private static final Logger logger = LoggerFactory.getLogger(DeleteUser.class);
private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
//(cron="second, minute, hour, day of month, month, day(s) of week")
@Scheduled(cron="0 0 8 * * *", zone="Asia/Kuala_Lumpur")
public void schedulerDeleteUser() {
List<User> ls = userService.getAllInactiveUser3Day(new Date());
try {
if(ls.size()>0) {
for(User user: ls) {
userService.updateStatusAccount(false, user.getId());
}
}
} …Run Code Online (Sandbox Code Playgroud)