Cassandra DataStax @Entity-Naterated类必须至少有一个属性定义
我在执行MVN清洁软件包/MVN清洁安装时使用了下面的实体类Java驱动程序4.1.x
package com.xyz;
import com.datastax.oss.driver.api.mapper.annotations.CqlName;
import com.datastax.oss.driver.api.mapper.annotations.Entity;
import com.datastax.oss.driver.api.mapper.annotations.PartitionKey;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Entity
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class Xyz {
@PartitionKey
@CqlName("id")
private Integer id;
@CqlName("name")
private String name;
@CqlName("description")
private String description;
}
,以下是错误(未编译实体类)
[xyz] @Entity-nartotation类必须至少具有一个定义的属性。
I have below Entity class used Datastax java driver 4.1.x
package com.xyz;
import com.datastax.oss.driver.api.mapper.annotations.CqlName;
import com.datastax.oss.driver.api.mapper.annotations.Entity;
import com.datastax.oss.driver.api.mapper.annotations.PartitionKey;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Entity
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class Xyz {
@PartitionKey
@CqlName("id")
private Integer id;
@CqlName("name")
private String name;
@CqlName("description")
private String description;
}
While doing mvn clean package/mvn clean install, getting below error (not compiled Entity class)
[Xyz] @Entity-annotated class must have at least one property defined.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对我有用的解决方案是在我的POM中包含以下配置:
最好将@data用于可变的对象或@Value作为不变的类型。
随着我在我的POM中添加上述内容,这对我有用:
您可以在DataStax文档中找到有关此信息的更多信息:
/EN/DEVELECTER/JAVA-DRIVER/4.10/MANUAL/MAPPER/CONFIG/LOMBOK/
The solution that worked for me is to include the below config in my pom:
It may be better to use @Data for mutable objects or @Value for immutable types.
With the addition of the above in my pom, this worked for me:
You can find more about this in the datastax documentation:
https://docs.datastax.com/en/developer/java-driver/4.10/manual/mapper/config/lombok/
在Gradle中,似乎按顺序处理注释处理器。我在Scylla注释处理器之前定义了Lombok注释处理器,并且它起作用。
作品:
不起作用:
In gradle, it seems like the annotation processors are processed in sequence. I defined the lombok annotation processor before the scylla annotation processor and it worked.
Works:
Doesn't work:
我面临同样的问题。我正在使用DataStax驱动程序4.15.0。注释处理在Intellijl中启用。看起来Lombok和DataStax存在问题。 Intellij可能是原因之一。我删除了以下内容
@getter
@setter
@noargsconstructor
@AllargSconstructor
生成的香草获取器,固定器和构造函数,并且有效!
I faced the same issue. I am using Datastax driver 4.15.0. Annotation processing is enabled in Intellijl. Looks like there is an issue with Lombok and datastax. Intellij can be one of the reasons. I removed the following
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
Generated vanilla getters,setters and constructors and it worked!