猿问

java Web项目关于hibernate整合Spring编译报错?

项目编译时报错,下面给的是控制台报错内容,看不懂报的是什么错,感觉是Spring容器sessionFactory出的错,下面也给了applicationContext.xml配置,求大神指导下!谢谢

报错内容:

严重: Context initialization failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/classes/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.connections.spi.ConnectionProvider]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)

at java.security.AccessController.doPrivileged(Native Method)



applicationContext.xml配置内容

<?xml version="1.0" encoding="UTF-8"?>

<beans

xmlns="http://www.springframework.org/schema/beans"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:p="http://www.springframework.org/schema/p"

xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

    <!-- 配置SessionFactory -->

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

<property name="dataSource" >

<ref local="dataSource"/>

</property>

<!-- 配置Hibernate的属性 -->

<property name="hibernateProperties">

<props>

<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>

<prop key="hibernate.show_sql">true</prop>

</props>

</property>

<!-- 指定HIbernate映射文件的路径 -->

<property name="mappingResources">

<list>

<value>com/integration/entity/User.hbm.xml</value>

</list>

</property>

  </bean>

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">

<property name="driverClassName">

<value>com.microsoft.sqlserver.jdbc.SQLServerDriver</value>

</property>

<property name="url">

<value>jdbc:sqlserver://localhost:1433;DatabaseName=shuihu

</value>

</property>

<property name="username">

<value>sa</value>

</property>

<property name="password">

<value>wu520zeng</value>

</property>

</bean>

    <bean id="userDAO"

class="com.integration.dao.UserDAOImpl"

abstract="false" lazy-init="default" autowire="default">

<property name="sessionFactory">

<ref bean="sessionFactory" />

</property>

</bean>  

<bean id="userService" class="com.integration.service.UserServiceImpl">

<property name="userDAO" ref="userDAO"></property>

</bean>  

<bean id="userAction" class="com.integration.action.UserAction">  

<property name="userService" ref="userService"></property>

</bean>

<bean id="loginAction" class="com.integration.action.LoginAction">

<property name="userService" ref="userService"></property>

</bean>  

<bean id="userDeleteAction" class="com.integration.action.UserDeleteAction">

<property name="userService" ref="userService"></property>

</bean>  

<bean id="userQueryAction" class="com.integration.action.UserQueryAction">

<property name="userService" ref="userService"></property>

</bean>  

<bean id="userUpdateAction" class="com.integration.action.UserUpdateAction">

<property name="userService" ref="userService"></property>

</bean>

</beans>


快乐学习520
浏览 1593回答 1
1回答

呵呵呵呵加呵呵呵

dataSource怎么配的?
随时随地看视频慕课网APP

相关分类

Java
我要回答