当运行项目时抛出这样的异常:Error creating bean with name 'DAOProxy' defined in class path resource [appcontext.xml]: Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [appcontext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [appcontext.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [appcontext.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClassName' threw exception; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Could not load JDBC driver class [com.microsoft.jdbc.sqlserver.SQLServerDriver]; nested exception is java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver我的配置文件为appcontext.xml,内容如下:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE beans PUBLIC "-//SPRING/DTD BEAN/EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
destroy-method="close">
<property name="driverClassName">
<value>com.microsoft.jdbc.sqlserver.SQLServerDriver</value>
</property>
<property name="url">
<value>jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=DB_JXC_Data</value>
</property>
<property name="username">
<value>sa</value>
</property>
<property name="password">
<value>820205</value>
</property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref local="dataSource"/>
</property>
<property name="mappingResources">
<list>
<value>appjxc/model/obj_medicine.hbm.xml</value>
<value>appjxc/model/Obj_gys.hbm.xml</value>
<value>appjxc/model/Obj_client.hbm.xml</value>
<value>appjxc/model/Obj_SellMain.hbm.xml</value>
<value>appjxc/model/Obj_SellDetaile.hbm.xml</value>
<value>appjxc/model/Obj_BuyMain.hbm.xml</value>
<value>appjxc/model/Obj_BuyDetaile.hbm.xml</value>
<value>appjxc/model/Obj_Stock.hbm.xml</value>
<value>appjxc/model/Obj_SellDetaileTh.hbm.xml</value>
<value>appjxc/model/Obj_UserName.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
<bean id="DAO" class="appjxc.dao.DaoSupport">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean> <bean id="DAOProxy"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager"/>
</property>
<property name="target">
<ref local="DAO"/>
</property>
<property name="proxyTargetClass" value="true"/>
<property name="transactionAttributes">
<props>
<prop key="insert*">PROPAGATION_REQUIRED</prop>
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean></beans>
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClassName' threw exception; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Could not load JDBC driver class [com.microsoft.jdbc.sqlserver.SQLServerDriver]; nested exception is java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver我的配置文件为appcontext.xml,内容如下:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE beans PUBLIC "-//SPRING/DTD BEAN/EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
destroy-method="close">
<property name="driverClassName">
<value>com.microsoft.jdbc.sqlserver.SQLServerDriver</value>
</property>
<property name="url">
<value>jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=DB_JXC_Data</value>
</property>
<property name="username">
<value>sa</value>
</property>
<property name="password">
<value>820205</value>
</property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref local="dataSource"/>
</property>
<property name="mappingResources">
<list>
<value>appjxc/model/obj_medicine.hbm.xml</value>
<value>appjxc/model/Obj_gys.hbm.xml</value>
<value>appjxc/model/Obj_client.hbm.xml</value>
<value>appjxc/model/Obj_SellMain.hbm.xml</value>
<value>appjxc/model/Obj_SellDetaile.hbm.xml</value>
<value>appjxc/model/Obj_BuyMain.hbm.xml</value>
<value>appjxc/model/Obj_BuyDetaile.hbm.xml</value>
<value>appjxc/model/Obj_Stock.hbm.xml</value>
<value>appjxc/model/Obj_SellDetaileTh.hbm.xml</value>
<value>appjxc/model/Obj_UserName.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
<bean id="DAO" class="appjxc.dao.DaoSupport">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean> <bean id="DAOProxy"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager"/>
</property>
<property name="target">
<ref local="DAO"/>
</property>
<property name="proxyTargetClass" value="true"/>
<property name="transactionAttributes">
<props>
<prop key="insert*">PROPAGATION_REQUIRED</prop>
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean></beans>
解决方案 »
- mvn install 编译好的class为什么都是小写的?
- 请问IT Script是什么
- 网上计时,什么方案比较方便准确?
- 关于如何动态的设定下拉列表的初始值
- 大家帮忙 领导让我将汉字拼音对照表插入到oracle库中 字段是(id,汉字,拼音) 啊 a 阿 a e 埃 ai 挨 ai 哎 ai 唉 ai 哀 ai,一个字还可能对
- 我做的购物车出现同一商家货物还清空
- 又是hibernate~~
- dom读xml异常求救
- 在tomcat中重新部署了war,如何不用重新启动tomcat?
- jdom输出格式问题.我在新增一条记录时,中间就多了一些黑的方块,怎么去掉呢.代码如下
- hibernate部分字段更新问题
- 安全设置
你有加驱动吗
一层层的解决就不是问题了
的确如2楼所说
你的数据库驱动引入不对