我正在从Sping Boot 2.7迁移到Sping Boot 3.0,我发现了一个error: cannot access MappedSuperclass
,我怀疑它来自JPA,我已经更改了jakemon的依赖关系和所有javax,但我仍然有以下错误,而且我没有在IDE中显示任何错误,只是我在运行时收到了日志。
这就是错误,我只想分享一部分,因为我不是太大,但都遵循相同的结构,只是在不同的功能。
> Task :compileJava FAILED
warning: unknown enum constant GenerationType.IDENTITY
reason: class file for javax.persistence.GenerationType not found
warning: unknown enum constant GenerationType.IDENTITY
warning: unknown enum constant FetchType.LAZY
reason: class file for javax.persistence.FetchType not found
warning: unknown enum constant CascadeType.ALL
reason: class file for javax.persistence.CascadeType not found
warning: unknown enum constant GenerationType.IDENTITY
warning: unknown enum constant FetchType.LAZY
warning: unknown enum constant CascadeType.ALL
warning: unknown enum constant GenerationType.IDENTITY
warning: unknown enum constant GenerationType.IDENTITY
error: cannot access MappedSuperclass
class file for javax.persistence.MappedSuperclass not found
/Users/paolabeltran/Documents/GitHub/ar-dispute-es-updater/src/main/java/com/ibm/ar/dispute/es/updater/utils/AttachmentPayloadConverter.java:24: error: cannot find symbol
payload.setCosAttachmentId(disputeAttachment.getAttachmentObjectStorageId());
^
symbol: method setCosAttachmentId(String)
location: variable payload of type AddAttachmentPayload
/Users/paolabeltran/Documents/GitHub/ar-dispute-es-updater/src/main/java/com/ibm/ar/dispute/es/updater/utils/AttachmentPayloadConverter.java:25: error: cannot find symbol
unknown enum constant GenerationType.IDENTITY
payload.setEsAttachmentRefId(disputeAttachmentEventData.getEsAttachmentRefId());
^
symbol: method setEsAttachmentRefId(String)
location: variable payload of type AddAttachmentPayload
/Users/paolabeltran/Documents/GitHub/ar-dispute-es-updater/src/main/java/com/ibm/ar/dispute/es/updater/utils/AttachmentPayloadConverter.java:26: error: cannot find symbol
payload.setFileName(disputeAttachment.getFileName());
unknown enum constant FetchType.LAZY
^
symbol: method setFileName(String)
unknown enum constant CascadeType.ALL
location: variable payload of type AddAttachmentPayload
unknown enum constant GenerationType.IDENTITY
unknown enum constant FetchType.LAZY
/Users/paolabeltran/Documents/GitHub/ar-dispute-es-updater/src/main/java/com/ibm/ar/dispute/es/updater/utils/AttachmentPayloadConverter.java:27: error: cannot find symbol
unknown enum constant CascadeType.ALL
unknown enum constant GenerationType.IDENTITY
payload.setFederalFlag(disputeAttachmentEventData.getFederalFlag());
^
cannot access MappedSuperclass
symbol: method setFederalFlag(String)
location: variable payload of type AddAttachmentPayload
/Users/paolabeltran/Documents/GitHub/ar-dispute-es-updater/src/main/java/com/ibm/ar/dispute/es/updater/utils/AttachmentPayloadConverter.java:28: error: cannot find symbol
payload.setTenantId(tenantId);
^
symbol: method setTenantId(String)
location: variable payload of type AddAttachmentPayload
/Users/paolabeltran/Documents/GitHub/ar-dispute-es-updater/src/main/java/com/ibm/ar/dispute/es/updater/utils/AttachmentPayloadConverter.java:29: error: cannot find symbol
payload.setCreatedBy(entitlement.getData().getEmail());
^
symbol: method setCreatedBy(String)
location: variable payload of type AddAttachmentPayload
/Users/paolabeltran/Documents/GitHub/ar-dispute-es-updater/src/main/java/com/ibm/ar/dispute/es/updater/utils/AttachmentPayloadConverter.java:36: error: cannot find symbol
String createdByMail = user.getContent().getMail()[0];
^
symbol: method getContent()
location: variable user of type BluepagesResponse
我收到错误的所有类都有相同的结构,所以我只展示一个例子
import jakarta.persistence.Entity;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class AddAttachmentPayload {
private String cosAttachmentId;
private String esAttachmentRefId;
private String fileName;
private String createdBy;
private String federalFlag;
private String tenantId;
}
这是我在build.gradle的依赖项
dependencies {
// Spring dependencies
implementation('org.springframework.boot:spring-boot-starter-web')
implementation('org.springframework.boot:spring-boot-starter-validation')
implementation('org.springframework.boot:spring-boot-starter-security')
implementation('org.springframework.boot:spring-boot-starter-data-jpa')
implementation('org.springframework.boot:spring-boot-starter-actuator')
implementation('org.springframework.boot:spring-boot-starter-data-redis')
annotationProcessor("org.springframework.boot:spring-boot-starter-data-jpa")
// Querydsl
//implementation group: 'com.querydsl', name: 'querydsl-jpa', version: querydslVersion
implementation("com.querydsl:querydsl-jpa:${querydslVersion}:jakarta")
implementation group: 'com.querydsl', name: 'querydsl-sql', version: querydslVersion
implementation group: 'com.querydsl', name: 'querydsl-sql-spring', version: querydslVersion
implementation group: 'com.querydsl', name: 'querydsl-apt', version: querydslVersion
implementation group: 'com.querydsl', name: 'querydsl-core', version: querydslVersion
annotationProcessor("com.querydsl:querydsl-apt:${querydslVersion}:jakarta")
annotationProcessor("jakarta.persistence:jakarta.persistence-api:3.1.0")
}
1条答案
按热度按时间qq24tv8q1#
我也遇到过这个错误,由于这个导入(MappedSuperClass),lombok的注解处理器中断,因此getter和setter的错误。在导入MappedSuperClass时使用javax,而不是jaklook,这些错误就会消失。你可以使用jaktool进行其他导入,除了:
而且效果很好
您可以通过在pom中包含以下内容来为MappedSuperClass使用javax import: