我尝试使用Spring Boot 3生成q-class,其中包含Jakarta Persistence、QueryDsl、Gradle和Intellij。但在运行./gradlew clean build
后,我无法生成q-class。构建后,我收到此错误:Unable to load class 'jakarta.persistence.Entity'. This is an unexpected error. Please file a bug containing the idea.log file.
我搜索了互联网,但没有找到解决问题的答案,因为Spring Boot版本3是最新的。
有人能帮帮我吗?
这是我的身材Gradle
plugins {
id 'org.springframework.boot' version '3.0.1'
id 'io.spring.dependency-management' version '1.1.0'
id 'java'
}
group = 'br.com.sammubr'
version = '0.0.1-SNAPSHOT'
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
ext {
set('springCloudVersion', "2022.0.0")
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
def queryDslVersion = '5.0.0'
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-validation'
runtimeOnly 'mysql:mysql-connector-java'
testImplementation 'org.springframework.security:spring-security-test'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
implementation 'io.micrometer:micrometer-registry-prometheus'
implementation("io.jsonwebtoken:jjwt-api:0.11.5")
runtimeOnly("io.jsonwebtoken:jjwt-impl:0.11.5")
runtimeOnly("io.jsonwebtoken:jjwt-jackson:0.11.5")
testImplementation 'org.testcontainers:testcontainers:1.17.5'
testImplementation 'org.testcontainers:mysql:1.17.5'
implementation 'com.lowagie:itext:2.1.7'
implementation 'com.github.wmixvideo:nfe:4.0.1'
implementation 'net.sf.jasperreports:jasperreports:6.20.0'
implementation 'com.google.zxing:core:3.5.1'
implementation 'net.sourceforge.barbecue:barbecue:1.5-beta1'
implementation("com.querydsl:querydsl-core:${queryDslVersion}")
implementation("com.querydsl:querydsl-jpa:${queryDslVersion}")
implementation('org.springframework.cloud:spring-cloud-starter-stream-rabbit')
implementation("com.github.ben-manes.caffeine:caffeine")
compileOnly 'org.projectlombok:lombok'
annotationProcessor(
"com.querydsl:querydsl-apt:${queryDslVersion}:jakarta",
"org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.2.Final",
"org.projectlombok:lombok"
)
}
tasks.named('test') {
useJUnitPlatform()
}
我的实体类示例:
package br.com.sammubr.admin.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.SuperBuilder;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDate;
import java.time.LocalDateTime;
@Entity
@Table(name = "activity")
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Activity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
private Long id;
@NotNull
@Size(max = 100)
@Column(name = "description", length = 100, nullable = false)
private String description;
}
1条答案
按热度按时间mtb9vblg1#
我终于得到了!
必须使用这些依赖项:
然后运行
./gradlew clean build
,q-classes将出现在文件夹build/generated/annotationProcessor
中