0

当我尝试遍历 BeanMap 中的条目集时,我得到一个

"java.lang.IllegalAccessException: Class org.apache.commons.beanutils.BeanMap can not access a member of class com.hello.Employee  with modifiers "public"  
    at org.apache.commons.beanutils.BeanMap.get(BeanMap.java:391)
    at org.apache.commons.beanutils.BeanMap$12.next(BeanMap.java:566)
    at org.apache.commons.collections.iterators.UnmodifiableIterator.next(UnmodifiableIterator.java:72)
    at org.codehaus.jackson.map.ser.std.MapSerializer.serializeFields(MapSerializer.java:232)
    at org.codehaus.jackson.map.ser.std.MapSerializer.serialize(MapSerializer.java:186)
    at org.codehaus.jackson.map.ser.std.MapSerializer.serialize(MapSerializer.java:23)
    at org.codehaus.jackson.map.ser.StdSerializerProvider._serializeValue(StdSerializerProvider.java:610)
    at org.codehaus.jackson.map.ser.StdSerializerProvider.serializeValue(StdSerializerProvider.java:256)
    at org.codehaus.jackson.map.ObjectWriter._configAndWriteValue(ObjectWriter.java:456)
    at org.codehaus.jackson.map.ObjectWriter.writeValueAsString(ObjectWriter.java:393)

知道是什么原因造成的吗?

4

1 回答 1

1

向类 `com.hello.Employee' 添加一个公共修饰符解决了这个问题。

于 2013-09-06T13:54:16.473 回答