spring-boot - joda-time、jadira 和休眠
问题描述
我正在将一个 spring-boot 项目迁移到 2.5 版本,这个项目正在使用 jadira 和 joda-time。
我试图弄清楚这些库的最新版本是否与 spring-boot 所需的 hibernate 5.4 兼容。
谢谢
<dependency>
<groupId>org.jadira.usertype</groupId>
<artifactId>usertype.core</artifactId>
<version>6.0.1.GA</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
解决方案
修复了实现 TypeContributor
public class JadiraTypesContributor implements TypeContributor
{
private static final UserType[] userTypes = new UserType[]{
new PersistentDateTime(),
new PersistentDurationAsString(),
new PersistentInstantAsMillisLong(),
new PersistentLocalDate(),
new PersistentLocalDateTime(),
new PersistentLocalTime(),
new PersistentMonthDayAsString(),
new PersistentPeriodAsString(),
new PersistentYears(),
new PersistentMinutes(),
};
private static final CompositeUserType[]
compositeUserTypes = new CompositeUserType[]{
new PersistentDateMidnight(),
new PersistentInterval(),
};
@Override
public void contribute(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
for (UserType userType : userTypes) {
typeContributions.contributeType(userType, userType.returnedClass().getName());
}
for (CompositeUserType compositeUserType : compositeUserTypes) {
typeContributions.contributeType(compositeUserType, compositeUserType.returnedClass().getName());
}
}
}
- 将类型贡献者添加到此文件
META-INF/services/org.hibernate.boot.model.TypeContributor
推荐阅读
- python - 是否可以为 Checkbutton 小部件(tkinter)设置 2 个不同的光标?
- javascript - 如何转义非标准(无效)的 HTML 标签?
- list - 有重复的列表(按顺序),其中一部分需要转移
- pyspark - pyspark crontab 触发重复(相同)作业
- ios - Facebook iOS SDK [NSNull 计数]:无法识别的选择器崩溃 BIG
- javascript - 在 Cognos 11 中使用 javascript 将数据添加到值提示
- python - Python:创建原始 ECC-ECDSA-SECP256R1 私有(32 字节)和公共(64 字节)密钥
- android - Android 10 on kill of app(即从最近的应用程序中刷出应用程序)用于检测互联网的作业调度程序无法正常工作
- nginx-config - Nginx 配置为图像服务器,但得到 403 禁止错误
- php - php htaccess seo 多语言