[英]Can I have a field in a @Document that is of the Class type?
I want to persist a document to MongoDB. 我想将文档保留到MongoDB。 I'm using Spring-Data-MongoDB to declare
@Document
s. 我正在使用Spring-Data-MongoDB声明
@Document
。 There is one particular document that is giving me problems. 有一个特定的文件给我带来了问题。 Below is an example the problematic document that has a field of the type
java.lang.Class
. 下面是一个有问题的文档示例,该文档的字段类型为
java.lang.Class
。
@Document
public class Value {
@Id
private Class<? extends I> clazz;
private Integer value;
...
}
The error that I get is below. 我得到的错误如下。
Caused by: java.lang.SecurityException: Can not make a java.lang.Class constructor accessible
My current solution is to use a String
instead of Class
. 我当前的解决方案是使用
String
而不是Class
。 I would appreciate any help on solving this issue of not being to use fields that are of the type Class
. 对于解决不使用
Class
类型字段的问题,我将不胜感激。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.