Error creating bean with name 'sessionFactory' defined

Exceptionsendingcontextinitializedeventtolistenerinstanceofclassorg.springframework.w... Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource': no matching editors or conversion strategy found
Caused by: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource': no matching editors or conversion strategy found
Caused by: java.lang.IllegalArgumentException: Cannot convert value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource': no matching editors or conversion strategy found
展开
 我来答
showerys
推荐于2018-03-21
知道答主
回答量:10
采纳率:0%
帮助的人:0
展开全部
Failed to convert property value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource'

这句话就是关键,你定义sessionFactory bean 的时候可能把该用<ref bean = "dataSource">的地方用了<value>dataSource</value>了吧????最好吧你的ApplicationContext.xml贴出来

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="configLocation">
<value>WEB-INF/classes/hibernate.cfg.xml</value>
</property>
<property name="hibernateProperties"
value="hibernate.dialect=org.hibernate.dialect.MySQLDialect" />
</bean>
逮荣花阴癸
2020-04-25 · TA获得超过3.5万个赞
知道大有可为答主
回答量:1.4万
采纳率:28%
帮助的人:1019万
展开全部
Failed
to
convert
property
value
of
type
[java.lang.String]
to
required
type
[javax.sql.DataSource]
for
property
'dataSource'
这句话就是关键,你定义sessionFactory
bean
的时候可能把该用<ref
bean
=
"dataSource">的地方用了<value>dataSource</value>了吧????最好吧你的ApplicationContext.xml贴出来

<bean
id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

<property
name="dataSource">

<ref
bean="dataSource"
/>

</property>

<property
name="configLocation">

<value>WEB-INF/classes/hibernate.cfg.xml</value>

</property>

<property
name="hibernateProperties"

value="hibernate.dialect=org.hibernate.dialect.MySQLDialect"
/>

</bean>
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式