spring+Struts+hibernate项目运行失败

发布于 2021-11-30 05:43:57 字数 4151 浏览 775 评论 5

spring framework4.0,Struts2.0,hibernate4.0构建的项目运行出错

applicationcontext.xml配置如下:

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost/zhdmk"/>
<property name="username" value="root"/>
<property name="password" value="lifei1234"/>
</bean>
   
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource"/>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/bean/User.hbm.xml</value>
</list>
</property>
</bean>
        <bean id="hibernateTemplate" class="org.springframework.orm.hibernate4.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
       
<bean id="userDao" class="com.dao.impl.UserDaoImpl">
<property name="hibernateTemplate">
<ref bean="hibernateTemplate"/>
</property>
</bean>


<bean id="userService" class="com.service.impl.UserServiceImpl">
<property name="userDao">
<ref bean="userDao"/>
</property>
</bean>


<bean id="userAddAction" class="com.action.UserAddAction" scope="prototype">
<property name="userService">
<ref bean="userService"/>
</property>
</bean>
错误信息如下:

Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'org.springframework.orm.hibernate4.HibernateTemplate' to required type 'org.springframework.orm.hibernate3.HibernateTemplate' for property 'hibernateTemplate'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.springframework.orm.hibernate4.HibernateTemplate] to required type [org.springframework.orm.hibernate3.HibernateTemplate] for property 'hibernateTemplate': no matching editors or conversion strategy found
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:474)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:511)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:505)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1502)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1461)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1197)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
... 56 more
Caused by: java.lang.IllegalStateException: Cannot convert value of type [org.springframework.orm.hibernate4.HibernateTemplate] to required type [org.springframework.orm.hibernate3.HibernateTemplate] for property 'hibernateTemplate': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:267)
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:459)
... 62 more


06-Apr-2016 19:46:25.693 INFO [http-apr-8888-exec-16] org.apache.catalina.core.ApplicationContext.log Closing Spring root WebApplicationContext


如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

伴我心暖 2021-12-01 17:50:08

各个jar版本配合嘛?

柒夜笙歌凉 2021-12-01 17:41:14

这么明显的
hibernate4和hibernate3

最偏执的依靠 2021-12-01 16:26:08

hibernate4.HibernateTemplate

hibernate3.HibernateTemplate

你这是闹啥。。

把回忆走一遍 2021-11-30 19:24:38

完全不看异常的吗

输什么也不输骨气 2021-11-30 08:44:16

醉了。

都不看异常的么?

Cannot convert value of type [org.springframework.orm.hibernate4.HibernateTemplate] to required type [org.springframework.orm.hibernate3.HibernateTemplate]

明显是hibernatetemplate import错版本了啊。

贴一段异常上来伸手要答案,比csdn上学生问作业还低级。。

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文