1

我有以下内容:

public class DifferentClass {
    Map<String,AnotherClass>someMap;
}

public class AnotherClass {
    Class<?> dataType;

    public void setDataType(Class<?> val) {
        this.dataType=val;
    }
}

public class A {
    ...
    public static class B {
        ...
    }
    ...
 }

以下spring bean配置:

<bean id="springRefName" class="my.project.path.to.DifferentClass">
...
<property name="someMap">
<map>
...
<entry key="someName">
<bean class= "my.project.path.to.AnotherClass">
<property name="dataType" value="my.project.path.to.A$B" />
</bean>
</entry>
...
</map >
</property>
...
</bean>

我遇到的问题是当我调用 dataType.getCanonicalName() 时,我只得到了 my.project.path.to.A。这让我相信 Spring 在转换为 Class 以分配给 AnotherClass.dataType 时会截断名称。我用 $ 和 a 都试过了。

4

0 回答 0