我使用spring boot starter数据cassandra reactive v2.0.0.M7与cassandra使用ReactiveApis进行交互。
我已经创建了Entity、Primarykey和Repository类。当我运行代码时,我遇到了以下异常。从最近几个小时以来,我一直试图解决这个问题,但没有成功。如果你需要更多信息,请告诉我。
Caused by: org.springframework.data.mapping.MappingException: Couldn't find PersistentEntity for type class java.lang.Object!
at org.springframework.data.mapping.context.MappingContext.getRequiredPersistentEntity(MappingContext.java:76) ~[spring-data-commons-2.0.2.RELEASE.jar:2.0.2.RELEASE]
at org.springframework.data.cassandra.repository.support.ReactiveCassandraRepositoryFactory.getEntityInformation(ReactiveCassandraRepositoryFactory.java:103) ~[spring-data-cassandra-2.0.2.RELEASE.jar:2.0.2.RELEASE]
at org.springframework.data.cassandra.repository.support.ReactiveCassandraRepositoryFactory.getTargetRepository(ReactiveCassandraRepositoryFactory.java:83) ~[spring-data-cassandra-2.0.2.RELEASE.jar:2.0.2.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:300) ~[spring-data-commons-2.0.2.RELEASE.jar:2.0.2.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$3(RepositoryFactoryBeanSupport.java:287) ~[spring-data-commons-2.0.2.RELEASE.jar:2.0.2.RELEASE]
at org.springframework.data.util.Lazy.getNullable(Lazy.java:141) ~[spring-data-commons-2.0.2.RELEASE.jar:2.0.2.RELEASE]
at org.springframework.data.util.Lazy.get(Lazy.java:63) ~[spring-data-commons-2.0.2.RELEASE.jar:2.0.2.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:290) ~[spring-data-commons-2.0.2.RELEASE.jar:2.0.2.RELEASE]
at org.springframework.data.cassandra.repository.support.ReactiveCassandraRepositoryFactoryBean.afterPropertiesSet(ReactiveCassandraRepositoryFactoryBean.java:99) ~[spring-data-cassandra-2.0.2.RELEASE.jar:2.0.2.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1769) ~[spring-beans-5.0.2.RELEASE.jar:5.0.2.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1706) ~[spring-beans-5.0.2.RELEASE.jar:5.0.2.RELEASE]
... 20 common frames omitted
相关代码段
@Table(name = "scan")
@Getter @Setter @NoArgsConstructor @ToString
public class CScan {
@PrimaryKey
private CScanPrimaryKey toolSourceIdKey;
@Column(name = "is_completed")
private String isCompleted;
@Column(name = "update_date")
private LocalDateTime updateDate;
@Column(name = "certification")
private String certification;
@Column(name = "audit_updated")
private String auditUpdated;
@Column(name = "sca_label")
private String scaLabel;
@Column(name = "sca_buildId")
private String scaBuildId;
@Column(name = "host_name")
private String hostName;
@Column(name = "start_date")
private LocalDateTime startDate;
@Column(name = "elapsed_time")
private int elapsedTime;
@Column(name = "has_issue")
private String hasIssue;
@Column(name = "updated")
private String updated;
@Column(name = "sca_files")
private int scaFiles;
@Column(name = "executable_loc")
private int executableLoc;
@Column(name = "total_loc")
private int totalLoc;
@Column(name = "engine_type")
private String engineType;
@Column(name = "engine_version")
private String engineVersion;
@Column(name = "guid")
private String guid;
@Column(name = "project_label")
private String projectLabel;
@Column(name = "version_label")
private String versionLabel;
@Column(name = "proj_ver_id")
private int projVerId;
@Column(name = "proj_ver_name")
private String projVerName;
@Column(name = "proj_id")
private int projId;
@Column(name = "proj_name")
private String projName;
@Column(name = "artifact_id")
private int artifact_id;
@Column(name = "object_version")
private int objectVersion;
@Column(name = "migrated")
private String migrated;
@Column(name = "server_version")
private Float serverVersion;
@Column(name = "entry_name")
private String entryName;
@Column(name = "fortify_annotations_loc")
private String fortifyAnnotationsLoc;
@Column(name = "data_version")
private String dataVersion;
}
@PrimaryKeyClass
@Getter @Setter @NoArgsConstructor @ToString @EqualsAndHashCode(exclude={})
public class CScanPrimaryKey implements Serializable {
/**
*
*/
private static final long serialVersionUID = 5703460462572087535L;
@PrimaryKeyColumn(name = "tool_source_id", type = PrimaryKeyType.PARTITIONED)
private UUID toolSourceId;
@PrimaryKeyColumn(name = "id", ordering = Ordering.ASCENDING)
private int id;
@PrimaryKeyColumn(name = "upload_status", ordering = Ordering.ASCENDING)
private String uploadStatus;
}
@Repository
public interface ReactiveScanRepository<CScan> extends ReactiveCassandraRepository<CScan, CScanPrimaryKey> {
}
2条答案
按热度按时间ecbunoof1#
尝试使用查询方法。
你可以这样做,
查询方法应该适用于大多数用例。对于复杂的自定义查询,请使用
@Query()
。dfuffjeb2#
我也有同样的问题。我可以通过在课堂上设置一个转折点来解决这个问题
通过检查链,您将能够找到无法示例化的类。对我来说,这是因为一个类没有正确扩展“ElasticsearchRepository”: