通常我将我的UUID以字符串形式存储到数据库中.在Spring Boot2.x中,我使用@Type(type = "org.hibernate.type.UUIDCharType")
来表示UUID.不知怎么的,在Spring Boot3.x中,它不再起作用了.它告诉我Cannot resolve method 'type'
.
我知道雅加达发生了一些变化,但我不知道这对我来说是不是一个问题.
我的实体:
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Type;
import java.util.Set;
import java.util.UUID;
@Data
@Entity
@Table(name = "werkstatt")
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class WerkstattEntity {
@Id
@Column(columnDefinition = "VARCHAR(255)")
@Type(type = "org.hibernate.type.UUIDCharType")
private UUID id;
}
我的格雷德副手:
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'org.mariadb.jdbc:mariadb-java-client'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'io.projectreactor:reactor-test'
testImplementation 'org.springframework.security:spring-security-test'
// https://mvnrepository.com/artifact/io.jsonwebtoken/jjwt-api
implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
// https://mvnrepository.com/artifact/io.jsonwebtoken/jjwt-impl
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5'
// https://mvnrepository.com/artifact/io.jsonwebtoken/jjwt-jackson
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.5'
implementation 'org.mapstruct:mapstruct:1.5.5.Final'
annotationProcessor 'org.mapstruct:mapstruct-processor:1.5.5.Final'
}