我已将shipmentProperties.xml
文件定义为:
<bean id = "shipmentProperties" class = "com.amazon.tfs.utils.Record" scope="prototype">
<constructor-arg type = "java.lang.String" value = "shipmentProperties" />
<property name = "schema">
<map>
<entry key = "shipmentProperty" value = "com.abc.xyz.data.types.ShipmentProperty" />
</map>
</property>
</bean>
在其他地方,我尝试使用
检索它myproperties = (Record) ApplicationBean.staticGetNonNullable("shipmentProperties");
if (myproperties == null) {
logger.info("It is pkgGTSDataCreationSstage and shipmentProperties can not be retrieved from bean");
}
ShipmentProperty prop = (ShipmentProperty) myproperties.get(shipmentProperty);
if (prop == null) {
logger.info("Object of class shipmentProperties can not be retrieved from bean");
}
现在问题是打印的输出是无法从bean中检索到类shipmentProperties
的对象。
我不明白为什么没有实例化?有人可以告诉我为什么会出现这个问题吗?
答案 0 :(得分:0)
ShipmentProperty
也需要标记为bean,因为shipmentProperties bean依赖于它。另外,我假设ShipmentProperty
类中有getter?
答案 1 :(得分:0)
尝试
<entry key = "shipmentProperty">
<bean class="com.abc.xyz.data.types.ShipmentProperty" />
</entry>
假设ShipmentProperty
构造函数不带参数。