开发者社区 问答 正文

Spring Bean 配置一个SimpleDateFormat为什么出错呢?? 400 报错

Spring Bean 配置一个SimpleDateFormat为什么出错呢?? 400 报错

搞不明白为什么报错BeanCreationException: Error creating bean with name 'commonSimpleDateFormat',Could not resolve matching constructor,按照平常的使用习惯,我可一直这么写:new SimpleDateFormat("yyyy-MM-dd HH����ss"),为什么spring就那么特俗了呢。


<bean id="commonSimpleDateFormat" class="java.text.SimpleDateFormat">
  <constructor-arg name="pattern" type="java.lang.String" value="yyyy-MM-dd HH����ss"/>
</bean>



展开
收起
爱吃鱼的程序员 2020-06-03 16:49:38 550 分享 版权
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB
    name="pattern"

    没有这几个字母.

    http://www.mkyong.com/spring/constructor-injection-type-ambiguities-in-spring/

    ######按照这么说来也没看出是什么问题,构造器的参数名是pattern,参数类型是String呢。######


    ######JDK自带的class基本都是非debug模式编译的,参数名没有带在class里面,所以去掉参数名
    ######OK,thank you,确实可以了。
    2020-06-03 20:48:45
    赞同 展开评论