Morphia映射豁免:org.springframework.security.access.intercept.AbstractSecurityInterceptor没有可用的构造函数

时间:2018-09-05 11:59:53

标签: java spring mongodb mongodb-query morphia

我正在使用Morphia映射pojos以实现MongoDB的持久性操作。虽然数据库连接也很好,但我还是出现了堆栈跟踪中所示的错误:

Exception in thread "main" org.mongodb.morphia.mapping.MappingException: No usable constructor for org.springframework.security.access.intercept.AbstractSecurityInterceptor
at org.mongodb.morphia.mapping.DefaultCreator.createInstance(DefaultCreator.java:81)
at org.mongodb.morphia.mapping.DefaultCreator.createInstance(DefaultCreator.java:91)
at org.mongodb.morphia.mapping.Mapper.fromDBObject(Mapper.java:192)
at org.mongodb.morphia.query.MorphiaIterator.convertItem(MorphiaIterator.java:134)
at org.mongodb.morphia.query.MorphiaIterator.processItem(MorphiaIterator.java:146)
at org.mongodb.morphia.query.MorphiaIterator.next(MorphiaIterator.java:117)
at org.mongodb.morphia.query.QueryImpl.asList(QueryImpl.java:147)
at org.mongodb.morphia.query.QueryImpl.asList(QueryImpl.java:139)
at de.hpi.ProcessorMongo.main(ProcessorMongo.java:52)
Caused by: java.lang.InstantiationException
at sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:48)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.mongodb.morphia.mapping.DefaultCreator.createInstance(DefaultCreator.java:72)
... 8 more

这是POJO:

public class AuditLog {

@Id
private ObjectId  logId;

@JsonProperty("@timestamp")
private String timestamp;
@JsonProperty("deviceId")
private String deviceId;
@JsonProperty("userId")
private String userId;
@JsonProperty("requestId")
private String requestId;
@JsonProperty("operationType")
private String operationType;

@JsonProperty("message")
private String message;
@JsonProperty("serviceName")
private String serviceName;
@JsonProperty("className")
private String className;

查询代码:

   MongoClient mongoClient = new MongoClient( "x.x.x.x" , 27017 );
   Morphia morphia = new Morphia();     
   morphia.mapPackage("a.b.c");
   final Datastore datastore = morphia.createDatastore(mongoClient, "myDB");
   datastore.getDB(); //.collectionExists("mycollection");
   datastore.ensureIndexes();             

   Query<AuditLog> query = datastore.find(AuditLog.class);
   final List<AuditLog> auditLog = query.asList();

   for (AuditLog logs : auditLog) {

    System.out.println(logs.getClassName() + "  " + logs.getDeviceId());
    }

对于可能存在问题或如何直接解决这些问题的任何指示,我将不胜感激。

0 个答案:

没有答案