I want to persist a document to MongoDB. I'm using Spring-Data-MongoDB to declare @Document
s. 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
.
@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
. I would appreciate any help on solving this issue of not being to use fields that are of the type Class
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.