糾正我已經發布:
在我的java類,我有:
@Autowired
@Qualifier("customerProviderExec")
private DefaultCustomerProvider customerProvider;
而且在我的上下文配置XML
<bean id="customerProviderExec" class="my.package.DefaultCustomerProviderExecutor">
<property name="defaultCustomerProviderService" ref="customerProviderImpl" />
</bean>
<bean id="testCustomerProviderImpl" class="my.package.DefaultCustomerProviderTest">
<property name="customerProviderImpl" ref="customerProviderImpl" />
</bean>
<bean id="customerProviderImpl" class="my.package.DefaultCustomerProviderImpl">
...
</bean>
重要:類DefaultCustomerProviderImpl實現DefaultCustomerProvider
當我嘗試在我的Java類來執行:
DefaultCustomerProviderExecutor executor = (DefaultCustomerProviderExecutor)this.getCustomerProvider();
return (DefaultCustomerProviderImpl) executor.getDefaultCustomerProviderService();
我得到的錯誤:
產生的原因:java.lang.ClassCastException:$ Proxy17不能轉換到my.package.DefaultCustomerProviderImpl
有人通過這個?
Impl - 4個字母,不應該是任何java類中的後綴;-) – Robin 2012-01-12 14:43:18