我正在为我们的 Spring 应用程序开发集成测试脚本。当我从 ant 运行测试时,我收到以下错误消息:任何理想的原因?
测试用例:
testgetDefaultItemForStoreWithInvalidStoreId(com.xyz.business.admin.role.RoleUtilityUnitTest):
Caused an ERROR Error creating bean with name 'groundingService' defined in URL
[file:/C:/workspace/_EACE1_0_06/EB_Ace_Vob/Business/build/classess/businessContext.xml]: Error
setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested
PropertyAccessExceptions (1) are: PropertyAccessException 1: org.springframework.beans.TypeMismatchException:
Failed to convert property value of type [$Proxy47] to required type
[com.xyz.business.grounding.service.OdometerPdfStatement] for property 'odometerPdfStatement'; nested exception
is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy47] to required type
[com.xyz.business.grounding.service.OdometerPdfStatement] for property 'odometerPdfStatement': no matching editors or
conversion strategy found org.springframework.beans.factory.BeanCreationException: Error creating bean with
name 'groundingService' defined in
URL [file:/C:/workspace/_EACE1_0_06/EB_Ace_Vob/Business/build/classess/businessContext.xml]: Error
setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested
PropertyAccessExceptions (1) are: PropertyAccessException 1: org.springframework.beans.TypeMismatchException:
Failed to convert property value of type [$Proxy47] to required type
[com.xyz.business.grounding.service.OdometerPdfStatement] for property 'odometerPdfStatement';
nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy47] to
required type [com.xyz.business.grounding.service.OdometerPdfStatement] for property 'odometerPdfStatement':
no matching editors or conversion strategy found Caused by:
org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessException details (1) are:
PropertyAccessException 1:
OdometerPDFStatement 是一个类(不是接口(interface))
我有以下内容:
<bean id="odometerPdfStatement" class="com.xyz.business.grounding.service.OdometerPdfStatement"/>
<bean id="groundingService" class="com.xyz.business.grounding.service.GroundingServiceImpl">
<property name="groundingInformationManager" ref="groundingInformationManager"/>
<property name="codeManager" ref="codeManager"/>
<property name="userManager" ref="userManager"/>
<property name="configurator" ref="groundingConfigurator"/>
<property name="velocityPropertyFilePath" value="velocity.properties"/>
<property name="velocityTemplate" value="OdometerStatement.vm"/>
<property name="odometerStatementXSLResourceFile" value="classpath:OdometerStatement2xsl-fo.xsl"/>
<property name="imagePropertyFile" value="classpath:images.properties"/>
<property name="odometerPdfStatement" ref="odometerPdfStatement"/>
<property name="inspectionInformationManager" ref="inspectionInformationManager"/>
<property name="saleEventManager" ref="saleEventManager"/>
<property name="vehicleHistoryManager" ref="vehicleHistoryManager"/>
</bean>
最佳答案
我遇到过几次这样的情况。这意味着spring创建的代理没有实现正确的接口(interface)。
我建议您在注入(inject)器上放置一个断点并检查 $Proxy47 以确定它正在实现什么。
另外,如果 om.xyz.business.grounding.service.OdometerPdfStatement 类实现了 2 个接口(interface),我不确定 spring 如何决定在代理时使用哪个接口(interface)。我怀疑它可能实现两个接口(interface),并且正在另一个接口(interface)上创建代理。
关于java - 与Spring集成测试: Cannot convert value of type error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1132915/