[英]Can I have a class field that is the Class<?> of a type that must extend another class and an interface?
[英]Can I have a field in a @Document that is of the Class type?
我想将文档保留到MongoDB。 我正在使用Spring-Data-MongoDB声明@Document
。 有一个特定的文件给我带来了问题。 下面是一个有问题的文档示例,该文档的字段类型为java.lang.Class
。
@Document
public class Value {
@Id
private Class<? extends I> clazz;
private Integer value;
...
}
我得到的错误如下。
Caused by: java.lang.SecurityException: Can not make a java.lang.Class constructor accessible
我当前的解决方案是使用String
而不是Class
。 对于解决不使用Class
类型字段的问题,我将不胜感激。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.