Spring 注入枚举数组

时间:2022-02-11 10:52:29

在spring的配置文件xml中

示例:

<!--注入枚举数組-->
<bean id="writeMapNullValue" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean">
<property name="staticField" value="com.alibaba.fastjson.serializer.SerializerFeature.WriteMapNullValue" />
</bean>
<bean id="WriteNullStringAsEmpty" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean">
<property name="staticField" value="com.alibaba.fastjson.serializer.SerializerFeature.WriteNullStringAsEmpty" />
</bean>
<bean id="fastJsonConfig" class="com.alibaba.fastjson.support.config.FastJsonConfig">
<property name="charset" value="utf-8" />
<property name="serializerFeatures" >
<array>
<ref bean="writeMapNullValue"/>
<ref bean="WriteNullStringAsEmpty"/>
</array>
</property>
</bean>