0
類沒有串行
讓我們假設一個簡單的User
類(只對樣品公共領域):春/註解的字段會導致這樣的發現
public class User {
public UserId userId;
}
public class UserId {
public String value = "1"; //hardcoded for the example
}
當春回大地,以使需求序列化涉及User
對象的遠程調用,UserId
字段被很好地序列化爲"1"
。
然而,當我註釋UserId
領域與一些春天註釋,在我的情況@Indexed
從Spring數據Neo4j的,我得到這個堆棧:`
RuntimeException: : org.codehaus.jackson.map.JsonMappingException: No serializer found for class com.model.user.UserId and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS)) (through reference chain: java.util.HashMap["value"]) (JsonHelper.java:77)
[error] org.neo4j.rest.graphdb.util.JsonHelper.createJsonFrom(JsonHelper.java:77)
[error] org.neo4j.rest.graphdb.ExecutingRestRequest.post(ExecutingRestRequest.java:140)
[error] org.neo4j.rest.graphdb.ExecutingRestAPI.addToIndex(ExecutingRestAPI.java:410)
[error] org.neo4j.rest.graphdb.RestAPIFacade.addToIndex(RestAPIFacade.java:166)
[error] org.neo4j.rest.graphdb.index.RestIndex.add(RestIndex.java:60)
註釋似乎導致這個突破。這是否有充分的理由?是否有序列化它的方法,儘管註釋存在?
它可能不完全相同的問題,但看看[這個問題](http://stackoverflow.com/questions/4362104/strange-jackson-exception-being-thrown-when-serializing-hibernate-對象) – zeroflagL
類似於:http://forum.spring.io/forum/spring-projects/data/nosql/110063-unable-to-convert-nodeentity-object-to-json-with-jackson – Mik378
你應該發佈一些真正的代碼並解釋你的真實用例(Spring Data Neo4j),因爲在你的例子中這個問題根本不存在。你的鏈接和我的解釋說,這個問題可能是由代理或加載時編織造成的。 – zeroflagL