Sping Boot 3升级错误:org.hibernate.annotations.Type missing element value

ltskdhd1  于 2023-11-21  发布在  其他
关注(0)|答案(1)|浏览(160)

我最近开始将Sping Boot 应用程序从2.2.4.RELEASE升级到3.0.0
虽然我想认为我设法做了很好的工作,解决问题,从升级到目前为止,这一个已经阻止了我很长一段时间了。
然而,当我触发测试套件时,我遇到了错误

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: org.hibernate.annotations.Type missing element value

    Caused by: java.lang.annotation.IncompleteAnnotationException: org.hibernate.annotations.Type missing element value
        at java.base/sun.reflect.annotation.AnnotationInvocationHandler.invoke(AnnotationInvocationHandler.java:86)

字符串
在测试类中我甚至没有任何@Type注解,所以我很困惑。
上面的错误是由我的所有测试产生的,产生错误的示例测试如下:

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;

import com.getyourguide.pricingalerts.Application;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class)
public class HomeEndpointsTest {
    @Test
    public void testReadiness() throws Exception {
        String response = "Ha";

        assertThat(response, is("Ok"));
    }


如果删除了@RunWith(SpringRunner.class)或@SpringBootTest(classes = Application.class)中的任何一个,则测试将按预期工作。仅当同时使用这两个选项时,才会发生错误。
我的build.gradle包含以下依赖项

dependencies {
    // https://mvnrepository.com/artifact/com.google.api-client/google-api-client-gson
    implementation 'com.google.api-client:google-api-client-gson:2.2.0'
    implementation 'org.springframework.boot:spring-boot-starter-validation:3.0.5'

    implementation 'org.springframework.boot:spring-boot-starter-data-jpa:3.0.5'
    annotationProcessor 'org.hibernate:hibernate-core-jakarta:5.6.15.Final'

    implementation 'javax.validation:validation-api:2.0.1.Final'

    implementation group: 'jakarta.xml.bind', name: 'jakarta.xml.bind-api', version: '4.0.0'
    implementation group: 'com.sun.xml.bind', name: 'jaxb-impl', version: '4.0.1'
    implementation group: 'org.glassfish.jaxb', name: 'jaxb-runtime', version: '4.0.2'

    // Spring MVC, testing, and devtools
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-webflux'

    // https://mvnrepository.com/artifact/io.netty/netty-transport
    implementation group: 'io.netty', name: 'netty-transport-native-epoll', version: '4.1.90.Final', classifier: 'linux-x86_64'
    implementation 'junit:junit:4.13.2'

    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testImplementation 'io.projectreactor:reactor-test'
    developmentOnly 'org.springframework.boot:spring-boot-devtools'
    // Lombok annotations to reduce boilerplate code
    compileOnly 'org.projectlombok:lombok:1.18.26'
    annotationProcessor 'org.projectlombok:lombok:1.18.26'
    // create MetaModel for jpa specification/
    annotationProcessor 'org.hibernate:hibernate-jpamodelgen:6.1.7.Final'
    implementation 'io.hypersistence:hypersistence-utils-hibernate-60:3.3.0'

    // Sentry
    implementation 'io.sentry:sentry-spring-boot-starter-jakarta:6.16.0'
    implementation 'io.sentry:sentry-logback:6.16.0'

    // DataDog
    datadogAgent group: 'com.datadoghq', name: 'dd-java-agent', version: '1.10.0'
    implementation group: 'com.datadoghq', name: 'dd-trace-api', version: '1.10.0'
    implementation 'com.datadoghq:java-dogstatsd-client:4.2.0'
    implementation 'io.micrometer:micrometer-registry-statsd:1.10.5'
    // Error Prone: (java error/antipattern checker - works with the net.ltgt.errorprone plugin above)
    errorprone 'com.google.errorprone:error_prone_core:2.18.0'
    // Database support
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    testImplementation 'net.ttddyy:datasource-proxy:1.8'
    // MySQL
    implementation 'org.mariadb.jdbc:mariadb-java-client:3.1.2'
    implementation 'com.h2database:h2:2.1.214'
    testImplementation 'mysql:mysql-connector-java:8.0.32'
    // Google sheets
    implementation 'com.google.api-client:google-api-client:2.2.0'
    implementation 'com.google.apis:google-api-services-sheets:v4-rev20230227-2.0.0'
    //s3
    implementation group: 'com.amazonaws', name: 'aws-java-sdk-s3', version: '1.12.429'
    //thymeleaf
    implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
    //testing
    testImplementation 'org.mockito:mockito-core:5.2.0'
}


我试过降级到SB 2.7,以防这是后来引入的一个变化,但这产生了一系列其他问题,所以我恢复了。
我已经检查过它运行的是Hibernate ORM核心版本6.1.5.Final,它应该与io兼容。hypersistence:hypersistence-utils-hibernate-60:3.0.1。
我尝试删除一些注解(见上文),以了解是否特定的注解会触发错误,但由于只有在同时使用两个注解时才会触发错误,因此我不确定。
我试着在slack上找到类似的问题,但似乎没有一个是完全正确的。
如果任何人有一个想法如何解决错误,或者如果我错过了一些关于如何正确升级的文档,我真的很感谢支持。
最好的,维克托

ckx4rj1h

ckx4rj1h1#

检查您的实体类是否有使用@Type注解的示例,替换为@JdbcTypeCode。

相关问题