Proxy cannot be cast to server.impl.ProductserviceImpl 解决方法!
点击下面标题查看本文完整版:Proxy cannot be cast to server.impl.ProductserviceImpl 解决方法!
我在DAO层建立了ProductMgmtImpl类,在SERVICE层建立了ProductserviceImpl类,然后将其配置到spring中的配置文件中
<!-- service -->
<bean id="productservice"
ref="ProductMgmtDAOImpl">
</property>
</bean>
然后测试ProductserviceImpl类时(测试代码如下)
ApplicationContext factory = new ClassPathXmlApplicationContext(
"applicationContext.xml");
private ProductserviceImpl Productservice= (ProductserviceImpl) factory.getBean("ProductserviceImpl ");
总报如下错误
ClassCastException: Proxy cannot be cast to server.impl.ProductserviceImpl
请问为什么从配置文件中读取ProductserviceImpl类时,不能转换成ProductserviceImpl类呢?
? ? 非常感谢!
------解决方法--------------------
private ProductserviceImpl Productservice= (ProductserviceImpl) factory.getBean("productservice");
欢迎加入java技术交流群,群号:50701307
------解决方法--------------------
<bean id="productservice"
class="service.impl.ProductserviceImpl">
private ProductserviceImpl Productservice= (ProductserviceImpl) factory.getBean("productservice");
?