ssm三大框架手动整合时遇到的错误与注意总结( 一)
2015-08-15 10:42
741 查看
当整合完,将项目部署到服务器时 Error creating bean with name 'filmTypeMapper' defined in file : 出现这个错误,一般都是mybatis的XML文件中的配置出现了错误
=======================================================
前端页面无法查出数据: 首先要分段寻找错误
1.查数据库连接(主要是看配置文件和spring.xml中数据源,sqlsessionfactory的配置)
2.如果连接正常,查看mybatis的mapper.xml的sql语句(对mybatis要进一步熟悉),测试是否能够查出数据
3.如果测试成功,则是向前端发送json数据时出错
(1)查看struts.xml是否写对(查看文档,如何进行json传输)
(2)查看是否导入了spring-json-plugin的包,注意要与spring核心包的版本一致
(3)如果上述的都没问题,则用firebug查看前端收到的响应
(4)如果收到响应,但是不能显示,则看JSON数据和easyui定义的字段名是否一致(注意大小写)
===================================================================================
mybatis使用。
(1)定义一个映射的接口,列出方法名
(2)每个映射接口对应创建一个xml文件,注意命名空间要与映射接口的全类名相同
(3)注册mapper.xml文件,
如果是在mybatis.xml单独使用中配置如下两种方法:
<!-- xml方式读取映射信息 -->
<mapper resource="com/yc/mybatis/entity/StudentMapper.xml"/>
<!-- 注解方式的读取映射信息,要在接口上加上@service -->
<package name="com.yc.mybatis.mapper"/>
<mapper class="com.yc.mybatis.mapper.StudentMapper"/>
如果是spring+mybatis整合,如下配置:
<!-- mybatis与spring整合 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<!-- 资源路径 -->
<property name="dataSource" ref="dataSource"/>
<!-- 实体类路径 -->
<property name="typeAliasesPackage" value="com.yc.ssm.cinema.entity"/>
<!-- 扫描mybatis.xml -->
<property name="mapperLocations" value="classpath:mapper/*Mapper.xml"/>
</bean>
<!-- 配置映射接口 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.yc.ssm.cinema.mapper"/>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
</bean>
==============================================================================
=======================================================
前端页面无法查出数据: 首先要分段寻找错误
1.查数据库连接(主要是看配置文件和spring.xml中数据源,sqlsessionfactory的配置)
2.如果连接正常,查看mybatis的mapper.xml的sql语句(对mybatis要进一步熟悉),测试是否能够查出数据
3.如果测试成功,则是向前端发送json数据时出错
(1)查看struts.xml是否写对(查看文档,如何进行json传输)
(2)查看是否导入了spring-json-plugin的包,注意要与spring核心包的版本一致
(3)如果上述的都没问题,则用firebug查看前端收到的响应
(4)如果收到响应,但是不能显示,则看JSON数据和easyui定义的字段名是否一致(注意大小写)
===================================================================================
mybatis使用。
(1)定义一个映射的接口,列出方法名
(2)每个映射接口对应创建一个xml文件,注意命名空间要与映射接口的全类名相同
(3)注册mapper.xml文件,
如果是在mybatis.xml单独使用中配置如下两种方法:
<!-- xml方式读取映射信息 -->
<mapper resource="com/yc/mybatis/entity/StudentMapper.xml"/>
<!-- 注解方式的读取映射信息,要在接口上加上@service -->
<package name="com.yc.mybatis.mapper"/>
<mapper class="com.yc.mybatis.mapper.StudentMapper"/>
如果是spring+mybatis整合,如下配置:
<!-- mybatis与spring整合 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<!-- 资源路径 -->
<property name="dataSource" ref="dataSource"/>
<!-- 实体类路径 -->
<property name="typeAliasesPackage" value="com.yc.ssm.cinema.entity"/>
<!-- 扫描mybatis.xml -->
<property name="mapperLocations" value="classpath:mapper/*Mapper.xml"/>
</bean>
<!-- 配置映射接口 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.yc.ssm.cinema.mapper"/>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
</bean>
==============================================================================
相关文章推荐
- Oracle优化:大量数据插入或更新
- 汉诺塔问题 Hanio ——递归思想
- 九度oj 1034
- php5.5及php5.6 wincache无法启用问题
- Caocao's Bridges
- 10个.NET中删除空白字符串的方法
- 开始使用git了.....
- JDK7、JDK8新特性
- 小贝_php源码安装
- 对于当下国产CPU如火如荼有感
- CodeForces 570D DFS序 树状数组 Tree Requests
- jvm内存回收机制
- Unity3D 5.1.2破解(亲测有效)
- WebApi参数传递总结
- UASCO Wormholes 解析 and C 语言实现
- thinkphp 源码分析(一)
- metasploit - sshexec
- 浅谈IT运维
- 关于二分查找
- CHOWN 用法