欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

错误:Property of 'java.util.Set' type cannot be injected by 'List'的解决方案

程序员文章站 2022-04-25 22:09:53
...

在自定义日期转换器的时候出现以下错误:

Property of 'java.util.Set<?>' type cannot be injected by 'List'

`

<bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
    <property name="converters">
        <list list-class="java.util.ArrayList">   <!--如果使用<list>此处报错,Property of 'java.util.Set<?>' type cannot be injected by 'List'-->
            <bean class="com.shop.controller.converter.CustomDateConverter"/>
        </list>
    </property>
</bean>

`

改为
`

<bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
    <property name="converters">
        <util:list list-class="java.util.ArrayList">
            <bean class="com.shop.controller.converter.CustomDateConverter"/>
        </util:list>
    </property>
</bean>

`
即可

我的个人博客