fala galera… blz?
estou aprendendo sobre spring… ou melhor… tentando… ehhehe
e fui tenta usar um CustomDateEditor para setar em uma variavel minha q recebe java.util.Date um valor passado como String… no meu arquivo XML do spring defini ele assim…
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="greetingService"
class="com.springinaction.chapter01.hello.impl.GreetingServiceImpl"
init-method="init" destroy-method="destroy">
<constructor-arg>
<value>Deu certo!?</value>
</constructor-arg>
<property name="greeting">
<value>E ae prego!</value>
</property>
<property name="date2">
<value>1982-09-15</value>
</property>
</bean>
<bean id="customEditorConfigurer"
class="org.springframework.beans.factory.config.CustomEditorConfigurer">
<property name="customEditors">
<map>
<entry key="java.util.Date">
<bean class="org.springframework.beans.propertyeditors.CustomDateEditor" >
<constructor-arg>
<bean class="java.text.SimpleDateFormat">
<constructor-arg type="java.lang.String">
<value>yyyy-MM-dd</value>
</constructor-arg>
</bean>
</constructor-arg>
<constructor-arg type="boolean">
<value>true</value>
</constructor-arg>
</bean>
</entry>
</map>
</property>
</bean>
</beans>
mas qdo executo minha classe de teste… ele lance o seguinte erro…
Exception in thread “main” org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘greetingService’ defined in file [C:\leco\eclipse\workspace\Spring\hello.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyAccessExceptionsException: PropertyAccessExceptionsException (1 errors); nested propertyAccessExceptions are: [org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [java.util.Date] for property ‘date2’]
PropertyAccessExceptionsException (1 errors)
org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [java.util.Date] for property ‘date2’
at org.springframework.beans.BeanWrapperImpl.doTypeConversionIfNecessary(BeanWrapperImpl.java:951)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:692)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:572)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:737)
at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:764)
at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:753)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1061)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:857)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:378)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:233)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:145)
at com.springinaction.chapter01.hello.HelloApp.main(HelloApp.java:19)
alguem tem alguma luz de onde eu esteja errando!? :assusta:
desde jah agradeço a ajuda de todos… :!: