Spring错误集

一、无法进行动态代理加强

原因:JDK本身自带的动态代理没办法代理实体类只有代理接口,妈耶,找死。

二、无法找到jdbcTemplate

原因:架包导入错误,导入了后缀带javadoc的架包= =事实证明要好好看名字啊orz

三、数据库连接失败

原因:1.配置文件driver写错——最常错,因为自带的连接和C3P0有些许差别。

           2.没有写类写成了接口

           3.配置文件里少写了连接池的配置文件

四、在整合过程中出现创建bean失败

原因:写错参数。根本原因,不明白<property>name的属性含义。还有就是,当

	<property name="mapperInterface" value="com.feicui.dao.StudentDao"></property>
这里不能用ref,要用value

name是根据名称获取值,所以当他需要创建对象时,应该用sqlSessionFactory这个方法来创建,而不应该用之前创建的工厂对象来实现其值。

正确配置
<bean id="studentDao" class="org.mybatis.spring.mapper.MapperFactoryBean">
		<property name="sqlSessionFactory" ref="sqlSessionFactoryBean" />
		<!-- 这里是映射文件读取 -->
		<property name="mapperInterface" value="com.feicui.dao.StudentDao"></property>
	</bean>
原错误配置
<bean id="studentDao" class="org.mybatis.spring.mapper.MapperFactoryBean">
		<property name="sqlSessionFactoryBean" ref="sqlSessionFactoryBean" />
		<!-- 这里是映射文件读取 -->
		<property name="mapperInterface" value="com.feicui.dao.StudentDao"></property>
	</bean>

猜你喜欢

转载自blog.csdn.net/rosemaryyoudu/article/details/84307058