ITeye博客

java.lang.ClassCastException: $Proxy1解决 Spring声明式事务配置上去后出现如下报错

wyyl00 · 2010-07-10 17:11 · ssh学习 · 企业架构 · Markdown

public static void main(String[] args) {
// TODO Auto-generated method stub
ApplicationContext cx = new FileSystemXmlApplicationContext("/src/applicationContext.xml");
CompanyDao company = (CompanyDao) cx.getBean("company");
company.insert("123");
}
仔细看下以上加粗地方,是不是采用配置的接口形式,如果不是改过来就OK了,如果采用实现了接口的类,例CompanyDaoImpl ,可以采用接口类型来强制转换
则要在配置文件applicationContext.xml代理类下增加属性:
<property name="proxyTargetClass">
   <value>true</value>
</property>
如果不实现接口,则要添加CGLIB到classpath

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。