@wenshao 你好,想跟你请教个问题:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlsessionFactory' defined in class path resource [spring.xml]: Cannot resolve reference to bean 'datasource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'datasource' is defined
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'datasource' is defined 我把项目的数据连接池从dbcp改为druid,启动tomcat就报错了,dbcp下是正常运行的,数据层的框架用的是mybatis ,期待您的回复,一个奋斗的程序员(JAY)
我的配置如下
<!-- 配置数据源 -->
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close">
<property name="url" value="${url}" />
<property name="username" value="${username}" />
<property name="password" value="${password}" />
<property name="filters" value="stat" />
<property name="maxActive" value="${maxPoolSize}" />
<property name="initialSize" value="${initialPoolSize}" />
<property name="maxWait" value="60000" />
<property name="minIdle" value="1" />
<property name="timeBetweenEvictionRunsMillis" value="60000" />
<property name="minEvictableIdleTimeMillis" value="300000" />
<property name="validationQuery" value="SELECT 'x'" />
<property name="testWhileIdle" value="true" />
<property name="testOnBorrow" value="false" />
<property name="testOnReturn" value="false" />
<property name="poolPreparedStatements" value="true" />
<property name="maxPoolPreparedStatementPerConnectionSize" value="20" />
</bean>
<bean id="sqlsessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="datasource"></property>
<property name="configLocation" value="classpath:mybatis.xml"/>
</bean>
<beanid=" dataSource"class="com.alibaba.druid.pool.DruidDataSource"destroy-method="close">
<beanid="sqlsessionFactory"class="org.mybatis.spring.SqlSessionFactoryBean">
<propertyname="dataSource"ref="
datasource
"></property>
<propertyname="configLocation"value="classpath:mybatis.xml"/>
</bean>
一个大写 一个小写 兄弟啊.....
回复 @灯光下的宁静:在哪评最佳答案的没弄过 @天使守护亲给最佳答案哦 @灯光下的宁静太感谢了绕在里面出不来了版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。