SSM框架整合,以CRM为例子
Posted 妮蔻
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SSM框架整合,以CRM为例子相关的知识,希望对你有一定的参考价值。
Mybatis、SpringMVC练习
CRM系统
- 回顾
Springmvc 高级参数绑定 数组 List
<input type name=ids /> 多个
方法 (Integer[] ids) QueryVo (里面Integer[] ids)
方法(QueryVo 里面List<Items> itemList
<input type name=itemList[${s.index}].name />
- 2. REquestMapping 处理器映射器(找此标签 路径 )
Value = {多个路径,}
Value = {/item/sfdsf.action} 类头上
Method=RequestMethod.POST或GET
3、 Controller方法返回值
三个
ModelAndView 建议不使用 不解偶
String 返回视图的路径 (形参 绑定Model ) 重定向redirect:另一个方法的映射路径 forward:内部转发
Void 异步请求使用
- 异常处理器
预期、运行时
自定义异常处理类 实现HandlerEexceptionResolver
由Spring实现化 自定义的处理类
未知异常
CustomEexception 继承Eexception
4、 上传图片
1)Form 上传图片了 action上传路径
2)input type=file name=picturePic
3)接收此图片 形参上绑定 MultipartFile picturePic 接口
4)配置此接口的实现类 Springmvc.xml配置CommonsMultipartFileResolver id=multipartFileResolver
5、JSON数据交互
应用场景:前端是各种 html Freemarker JSP一个Servlet 是Java代码 jstl C
浏览器 Ajax 发送JSON字符串 报文
6、拦截器
拦截器 应用 (练习)
1 CRM项目外观
1. 开发环境
IDE: Eclipse Mars2
Jdk: 1.7
数据库: mysql
2. 创建数据库
数据库sql文件如下:
/* Navicat MySQL Data Transfer Source Server : localhost_3306 Source Server Version : 50611 Source Host : localhost:3306 Source Database : crm Target Server Type : MYSQL Target Server Version : 50611 File Encoding : 65001 Date: 2016-05-12 00:07:42 */ SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for base_dict -- ---------------------------- DROP TABLE IF EXISTS `base_dict`; CREATE TABLE `base_dict` ( `dict_id` varchar(32) NOT NULL COMMENT \'数据字典id(主键)\', `dict_type_code` varchar(10) NOT NULL COMMENT \'数据字典类别代码\', `dict_type_name` varchar(64) NOT NULL COMMENT \'数据字典类别名称\', `dict_item_name` varchar(64) NOT NULL COMMENT \'数据字典项目名称\', `dict_item_code` varchar(10) DEFAULT NULL COMMENT \'数据字典项目代码(可为空)\', `dict_sort` int(10) DEFAULT NULL COMMENT \'排序字段\', `dict_enable` char(1) NOT NULL COMMENT \'1:使用 0:停用\', `dict_memo` varchar(64) DEFAULT NULL COMMENT \'备注\', PRIMARY KEY (`dict_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of base_dict -- ---------------------------- INSERT INTO `base_dict` VALUES (\'1\', \'001\', \'客户行业\', \'教育培训 \', null, \'1\', \'1\', null); INSERT INTO `base_dict` VALUES (\'10\', \'003\', \'公司性质\', \'民企\', null, \'3\', \'1\', null); INSERT INTO `base_dict` VALUES (\'12\', \'004\', \'年营业额\', \'1-10万\', null, \'1\', \'1\', null); INSERT INTO `base_dict` VALUES (\'13\', \'004\', \'年营业额\', \'10-20万\', null, \'2\', \'1\', null); INSERT INTO `base_dict` VALUES (\'14\', \'004\', \'年营业额\', \'20-50万\', null, \'3\', \'1\', null); INSERT INTO `base_dict` VALUES (\'15\', \'004\', \'年营业额\', \'50-100万\', null, \'4\', \'1\', null); INSERT INTO `base_dict` VALUES (\'16\', \'004\', \'年营业额\', \'100-500万\', null, \'5\', \'1\', null); INSERT INTO `base_dict` VALUES (\'17\', \'004\', \'年营业额\', \'500-1000万\', null, \'6\', \'1\', null); INSERT INTO `base_dict` VALUES (\'18\', \'005\', \'客户状态\', \'基础客户\', null, \'1\', \'1\', null); INSERT INTO `base_dict` VALUES (\'19\', \'005\', \'客户状态\', \'潜在客户\', null, \'2\', \'1\', null); INSERT INTO `base_dict` VALUES (\'2\', \'001\', \'客户行业\', \'电子商务\', null, \'2\', \'1\', null); INSERT INTO `base_dict` VALUES (\'20\', \'005\', \'客户状态\', \'成功客户\', null, \'3\', \'1\', null); INSERT INTO `base_dict` VALUES (\'21\', \'005\', \'客户状态\', \'无效客户\', null, \'4\', \'1\', null); INSERT INTO `base_dict` VALUES (\'22\', \'006\', \'客户级别\', \'普通客户\', null, \'1\', \'1\', null); INSERT INTO `base_dict` VALUES (\'23\', \'006\', \'客户级别\', \'VIP客户\', null, \'2\', \'1\', null); INSERT INTO `base_dict` VALUES (\'24\', \'007\', \'商机状态\', \'意向客户\', null, \'1\', \'1\', null); INSERT INTO `base_dict` VALUES (\'25\', \'007\', \'商机状态\', \'初步沟通\', null, \'2\', \'1\', null); INSERT INTO `base_dict` VALUES (\'26\', \'007\', \'商机状态\', \'深度沟通\', null, \'3\', \'1\', null); INSERT INTO `base_dict` VALUES (\'27\', \'007\', \'商机状态\', \'签订合同\', null, \'4\', \'1\', null); INSERT INTO `base_dict` VALUES (\'3\', \'001\', \'客户行业\', \'对外贸易\', null, \'3\', \'1\', null); INSERT INTO `base_dict` VALUES (\'30\', \'008\', \'商机类型\', \'新业务\', null, \'1\', \'1\', null); INSERT INTO `base_dict` VALUES (\'31\', \'008\', \'商机类型\', \'现有业务\', null, \'2\', \'1\', null); INSERT INTO `base_dict` VALUES (\'32\', \'009\', \'商机来源\', \'电话营销\', null, \'1\', \'1\', null); INSERT INTO `base_dict` VALUES (\'33\', \'009\', \'商机来源\', \'网络营销\', null, \'2\', \'1\', null); INSERT INTO `base_dict` VALUES (\'34\', \'009\', \'商机来源\', \'推广活动\', null, \'3\', \'1\', null); INSERT INTO `base_dict` VALUES (\'4\', \'001\', \'客户行业\', \'酒店旅游\', null, \'4\', \'1\', null); INSERT INTO `base_dict` VALUES (\'5\', \'001\', \'客户行业\', \'房地产\', null, \'5\', \'1\', null); INSERT INTO `base_dict` VALUES (\'6\', \'002\', \'客户信息来源\', \'电话营销\', null, \'1\', \'1\', null); INSERT INTO `base_dict` VALUES (\'7\', \'002\', \'客户信息来源\', \'网络营销\', null, \'2\', \'1\', null); INSERT INTO `base_dict` VALUES (\'8\', \'003\', \'公司性质\', \'合资\', null, \'1\', \'1\', null); INSERT INTO `base_dict` VALUES (\'9\', \'003\', \'公司性质\', \'国企\', null, \'2\', \'1\', null); -- ---------------------------- -- Table structure for customer -- ---------------------------- DROP TABLE IF EXISTS `customer`; CREATE TABLE `customer` ( `cust_id` bigint(32) NOT NULL AUTO_INCREMENT COMMENT \'客户编号(主键)\', `cust_name` varchar(32) NOT NULL COMMENT \'客户名称(公司名称)\', `cust_user_id` bigint(32) DEFAULT NULL COMMENT \'负责人id\', `cust_create_id` bigint(32) DEFAULT NULL COMMENT \'创建人id\', `cust_source` varchar(32) DEFAULT NULL COMMENT \'客户信息来源\', `cust_industry` varchar(32) DEFAULT NULL COMMENT \'客户所属行业\', `cust_level` varchar(32) DEFAULT NULL COMMENT \'客户级别\', `cust_linkman` varchar(64) DEFAULT NULL COMMENT \'联系人\', `cust_phone` varchar(64) DEFAULT NULL COMMENT \'固定电话\', `cust_mobile` varchar(16) DEFAULT NULL COMMENT \'移动电话\', `cust_zipcode` varchar(10) DEFAULT NULL, `cust_address` varchar(100) DEFAULT NULL, `cust_createtime` datetime DEFAULT NULL COMMENT \'创建时间\', PRIMARY KEY (`cust_id`), KEY `FK_cst_customer_source` (`cust_source`), KEY `FK_cst_customer_industry` (`cust_industry`), KEY `FK_cst_customer_level` (`cust_level`), KEY `FK_cst_customer_user_id` (`cust_user_id`), KEY `FK_cst_customer_create_id` (`cust_create_id`) ) ENGINE=InnoDB AUTO_INCREMENT=162 DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of customer -- ---------------------------- INSERT INTO `customer` VALUES (\'14\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:01\'); INSERT INTO `customer` VALUES (\'15\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:01\'); INSERT INTO `customer` VALUES (\'16\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:01\'); INSERT INTO `customer` VALUES (\'17\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:02\'); INSERT INTO `customer` VALUES (\'22\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:03\'); INSERT INTO `customer` VALUES (\'24\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:03\'); INSERT INTO `customer` VALUES (\'25\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:03\'); INSERT INTO `customer` VALUES (\'26\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:03\'); INSERT INTO `customer` VALUES (\'28\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:04\'); INSERT INTO `customer` VALUES (\'29\', \'令狐冲\', null, null, \'7\', \'1\', \'23\', \'任盈盈\', \'0108888886\', \'13888888886\', \'6123456\', \'北京三里桥6\', \'2016-04-08 16:32:04\'); INSERT INTO `customer` VALUES (\'30\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:04\'); INSERT INTO `customer` VALUES (\'31\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:04\'); INSERT INTO `customer` VALUES (\'33\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:04\'); INSERT INTO `customer` VALUES (\'34\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:05\'); INSERT INTO `customer` VALUES (\'35\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:05\'); INSERT INTO `customer` VALUES (\'36\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:05\'); INSERT INTO `customer` VALUES (\'37\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:05\'); INSERT INTO `customer` VALUES (\'38\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:05\'); INSERT INTO `customer` VALUES (\'39\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:06\'); INSERT INTO `customer` VALUES (\'40\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:06\'); INSERT INTO `customer` VALUES (\'41\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:06\'); INSERT INTO `customer` VALUES (\'42\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:06\'); INSERT INTO `customer` VALUES (\'43\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:06\'); INSERT INTO `customer` VALUES (\'44\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:07\'); INSERT INTO `customer` VALUES (\'45\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:07\'); INSERT INTO `customer` VALUES (\'46\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:07\'); INSERT INTO `customer` VALUES (\'47\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:07\'); INSERT INTO `customer` VALUES (\'48\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:07\'); INSERT INTO `customer` VALUES (\'49\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:07\'); INSERT INTO `customer` VALUES (\'50\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:08\'); INSERT INTO `customer` VALUES (\'51\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:08\'); INSERT INTO `customer` VALUES (\'52\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:08\'); INSERT INTO `customer` VALUES (\'53\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:08\'); INSERT INTO `customer` VALUES (\'54\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:08\'); INSERT INTO `customer` VALUES (\'55\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:08\'); INSERT INTO `customer` VALUES (\'56\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:09\'); INSERT INTO `customer` VALUES (\'57\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:09\'); INSERT INTO `customer` VALUES (\'58\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:09\'); INSERT INTO `customer` VALUES (\'59\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:29\'); INSERT INTO `customer` VALUES (\'60\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:29\'); INSERT INTO `customer` VALUES (\'61\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:29\'); INSERT INTO `customer` VALUES (\'62\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:29\'); INSERT INTO `customer` VALUES (\'63\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:30\'); INSERT INTO `customer` VALUES (\'64\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:30\'); INSERT INTO `customer` VALUES (\'65\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:30\'); INSERT INTO `customer` VALUES (\'66\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:30\'); INSERT INTO `customer` VALUES (\'67\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:30\'); INSERT INTO `customer` VALUES (\'68\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:30\'); INSERT INTO `customer` VALUES (\'69\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:31\'); INSERT INTO `customer` VALUES (\'70\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:31\'); INSERT INTO `customer` VALUES (\'71\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:31\'); INSERT INTO `customer` VALUES (\'72\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:31\'); INSERT INTO `customer` VALUES (\'73\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:31\'); INSERT INTO `customer` VALUES (\'74\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:32\'); INSERT INTO `customer` VALUES (\'75\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:32\'); INSERT INTO `customer` VALUES (\'76\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:32\'); INSERT INTO `customer` VALUES (\'77\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:32\'); INSERT INTO `customer` VALUES (\'78\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:32\'); INSERT INTO `customer` VALUES (\'79\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:32\'); INSERT INTO `customer` VALUES (\'80\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:33\'); INSERT INTO `customer` VALUES (\'81\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:33\'); INSERT INTO `customer` VALUES (\'82\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:33\'); INSERT INTO `customer` VALUES (\'83\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:33\'); INSERT INTO `customer` VALUES (\'84\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:33\'); INSERT INTO `customer` VALUES (\'85\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:33\'); INSERT INTO `customer` VALUES (\'86\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:34\'); INSERT INTO `customer` VALUES (\'87\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:34\'); INSERT INTO `customer` VALUES (\'88\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:34\'); INSERT INTO `customer` VALUES (\'89\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:34\'); INSERT INTO `customer` VALUES (\'90\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:34\'); INSERT INTO `customer` VALUES (\'91\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:34\'); INSERT INTO `customer` VALUES (\'92\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:35\'); INSERT INTO `customer` VALUES (\'93\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:35\'); INSERT INTO `customer` VALUES (\'94\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:35\'); INSERT INTO `customer` VALUES (\'95\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:35\'); INSERT INTO `customer` VALUES (\'96\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:35\'); INSERT INTO `customer` VALUES (\'97\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:36\'); INSERT INTO `customer` VALUES (\'98\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:36\'); INSERT INTO `customer` VALUES (\'99\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:36\'); INSERT INTO `customer` VALUES (\'100\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:36\'); INSERT INTO `customer` VALUES (\'101\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:36\'); INSERT INTO `customer` VALUES (\'102\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:36\'); INSERT INTO `customer` VALUES (\'103\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:37\'); INSERT INTO `customer` VALUES (\'104\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:37\'); INSERT INTO `customer` VALUES (\'105\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:37\'); INSERT INTO `customer` VALUES (\'106\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:37\'); INSERT INTO `customer` VALUES (\'107\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:37\'); INSERT INTO `customer` VALUES (\'108\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:38\'); INSERT INTO `customer` VALUES (\'109\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:38\'); INSERT INTO `customer` VALUES (\'110\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:38\'); INSERT INTO `customer` VALUES (\'111\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:38\'); INSERT INTO `customer` VALUES (\'112\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:38\'); INSERT INTO `customer` VALUES (\'113\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:38\'); INSERT INTO `customer` VALUES (\'114\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:39\'); INSERT INTO `customer` VALUES (\'115\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:39\'); INSERT INTO `customer` VALUES (\'116\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:39\'); INSERT INTO `customer` VALUES (\'117\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:39\'); INSERT INTO `customer` VALUES (\'118\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:39\'); INSERT INTO `customer` VALUES (\'119\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:40\'); INSERT INTO `customer` VALUES (\'120\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:40\'); INSERT INTO `customer` VALUES (\'121\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:40\'); INSERT INTO `customer` VALUES (\'122\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:40\'); INSERT INTO `customer` VALUES (\'123\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:40\'); INSERT INTO `customer` VALUES (\'124\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:40\'); INSERT INTO `customer` VALUES (\'125\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:41\'); INSERT INTO `customer` VALUES (\'126\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:41\'); INSERT INTO `customer` VALUES (\'127\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:41\'); INSERT INTO `customer` VALUES (\'128\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:41\'); INSERT INTO `customer` VALUES (\'129\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:41\'); INSERT INTO `customer` VALUES (\'130\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:42\'); INSERT INTO `customer` VALUES (\'131\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:42\'); INSERT INTO `customer` VALUES (\'132\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:42\'); INSERT INTO `customer` VALUES (\'133\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:42\'); INSERT INTO `customer` VALUES (\'134\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:42\'); INSERT INTO `customer` VALUES (\'135\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:42\'); INSERT INTO `customer` VALUES (\'136\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:43\'); INSERT INTO `customer` VALUES (\'137\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:43\'); INSERT INTO `customer` VALUES (\'138\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:43\'); INSERT INTO `customer` VALUES (\'139\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:43\'); INSERT INTO `customer` VALUES (\'140\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:43\'); INSERT INTO `customer` VALUES (\'141\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:44\'); INSERT INTO `customer` VALUES (\'142\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:44\'); INSERT INTO `customer` VALUES (\'143\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:44\'); INSERT INTO `customer` VALUES (\'144\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:44\'); INSERT INTO `customer` VALUES (\'145\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:44\'); INSERT INTO `customer` VALUES (\'146\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:44\'); INSERT INTO `customer` VALUES (\'147\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:45\'); INSERT INTO `customer` VALUES (\'148\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:45\'); INSERT INTO `customer` VALUES (\'149\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:45\'); INSERT INTO `customer` VALUES (\'150\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:45\'); INSERT INTO `customer` VALUES (\'151\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:45\'); INSERT INTO `customer` VALUES (\'152\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:46\'); INSERT INTO `customer` VALUES (\'153\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:46\'); INSERT INTO `customer` VALUES (\'154\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:46\'); INSERT INTO `customer` VALUES (\'155\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:46\'); INSERT INTO `customer` VALUES (\'156\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:46\'); INSERT INTO `customer` VALUES (\'157\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:46\'); INSERT INTO `customer` VALUES (\'158\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:47\'); INSERT INTO `customer` VALUES (\'159\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:47\'); INSERT INTO `customer` VALUES (\'160\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:47\'); INSERT INTO `customer` VALUES (\'161\', \'马云\', null, null, \'6\', \'2\', \'22\', \'马化腾\', \'0108888887\', \'13888888888\', \'123456\', \'北京三里桥\', \'2016-04-08 16:32:47\'); -- ---------------------------- -- Table structure for sys_user -- ---------------------------- DROP TABLE IF EXISTS `sys_user`; CREATE TABLE `sys_user` ( `user_id` bigint(32) NOT NULL AUTO_INCREMENT COMMENT \'用户id\', `user_code` varchar(32) NOT NULL COMMENT \'用户账号\', `user_name` varchar(64) NOT NULL COMMENT \'用户名称\', `user_password` varchar(32) NOT NULL COMMENT \'用户密码\', `user_state` char(1) NOT NULL COMMENT \'1:正常,0:暂停\', PRIMARY KEY (`user_id`) ) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of sys_user -- ---------------------------- INSERT INTO `sys_user` VALUES (\'5\', \'m0003\', \'小军\', \'123\', \'1\'); INSERT INTO `sys_user` VALUES (\'6\', \'m0001\', \'小红\', \'123\', \'1\'); INSERT INTO `sys_user` VALUES (\'7\', \'m0001\', \'小明\', \'123\', \'1\'); INSERT INTO `sys_user` VALUES (\'8\', \'m0001\', \'小红\', \'123\', \'1\');
创建crm数据库,执行sql
效果如下图:
3. 工程搭建
使用的Bootstrap前端框架,官方网站
http://www.bootcss.com/
工程使用Springmvc、spring、mybatis框架整合完成。
3.1. 需要的jar包
- spring(包括springmvc)
- mybatis
- mybatis-spring整合包
- 数据库驱动
- 第三方连接池。
- Json依赖包Jackson
jar包位置如下图:
3.2. 整合思路
Dao层:
1、SqlMapConfig.xml,空文件即可,但是需要文件头。
2、applicationContext-dao.xml
a) 数据库连接Druid
b) SqlSessionFactory对象,需要spring和mybatis整合包下的。
c) 配置mapper文件扫描器。Mapper动态代理开发 增强版
Service层:
1、applicationContext-service.xml包扫描器,扫描@service注解的类。
2、applicationContext-trans.xml配置事务。
Controller层:
1、Springmvc.xml
a) 包扫描器,扫描@Controller注解的类。
b) 配置注解驱动
c) 配置视图解析器
Web.xml文件:
1、配置spring监听器
2、配置前端控制器。
3.3. 创建工程
创建动态web工程,步骤如下图:
创建boot-crm,如下图
3.4. 加入jar包
加入资料中的jar包
3.5. 加入配置文件
创建config资源文件夹,在里面创建mybatis和spring文件夹
3.5.1. SqlMapConfig.xml
空文件即可
1 <?xml version="1.0" encoding="UTF-8" ?> 2 <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" 3 "http://mybatis.org/dtd/mybatis-3-config.dtd"> 4 <configuration> 5 6 7 8 </configuration>
3.5.2. applicationContext-dao.xml
需要配置:
加载properties文件,数据源,SqlSessionFactory,Mapper扫描
1 <?xml version="1.0" encoding="UTF-8"?> 2 <beans xmlns="http://www.springframework.org/schema/beans" 3 xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p" 4 xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" 5 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 6 xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd 7 http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd 8 http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd 9 http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd"> 10 11 <!-- 配置 读取properties文件 jdbc.properties --> 12 <context:property-placeholder location="classpath:jdbc.properties" /> 13 14 <!-- 配置 数据源 --> 15 <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"> 16 <property name="driverClassName" value="${jdbc.driver}" /> 17 <property name="url" value="${jdbc.url}" /> 18 <property name="username" value="${jdbc.username}" /> 19 <property name="password" value="${jdbc.password}" /> 20 </bean> 21 22 <!-- 配置SqlSessionFactory --> 23 <bean class="org.mybatis.spring.SqlSessionFactoryBean"> 24 <!-- 设置MyBatis核心配置文件 --> 25 <property name="configLocation" value="classpath:mybatis/SqlMapConfig.xml" /> 26 <!-- 设置数据源 --> 27 <property name="dataSource" ref="dataSource" /> 28 </bean> 29 30 <!-- 配置Mapper扫描 --> 31 <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> 32 <!-- 设置Mapper扫描包 --> 33 <property name="basePackage" value="cn.itcast.crm.mapper" /> 34 </bean> 35 </beans>
3.5.3. jdbc.properties
配置数据库信息
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/crm?characterEncoding=utf-8
jdbc.username=root
jdbc.password=root
3.5.4. log4j.properties
配置日志信息
1 # Global logging configuration 2 log4j.rootLogger=DEBUG, stdout 3 # Console output... 4 log4j.appender.stdout=org.apache.log4j.ConsoleAppender 5 log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 6 log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n
3.5.5. applicationContext-service.xml
配置service扫描
1 <?xml version="1.0" encoding="UTF-8"?> 2 <beans xmlns="http://www.springframework.org/schema/beans" 3 xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p" 4 xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" 5 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 6 xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd 7 http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd 8 http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd 9 http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd"> 10 11 <!-- 配置Service扫描 --> 12 <context:component-scan base-package="cn.itcast.crm.service" /> 13 </beans>
3.5.6. applicationContext-trans.xml
配置事务管理:事务管理器、通知、切面
1 <?xml version="1.0" encoding="UTF-8"?> 2 <beans xmlns="http://www.springframework.org/schema/beans" 3 xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p" 4 xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" 5 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 6 xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd 7 http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd 8 http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd 9 http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd"> 10 11 <!-- 事务管理器 --> 12 <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> 13 <!-- 数据源 --> 14 <property name="dataSource" ref="dataSource" /> 15 </bean> 16 17 <!-- 通知 --> 18 <tx:advice id="txAdvice" transaction-manager="transactionManager"> 19 <tx:attributes> 20 <!-- 传播行为 --> 21 <tx:method name="save*" propagation="REQUIRED" /> 22 <tx:method name="insert*" propagation="REQUIRED" /> 23 <tx:method name="add*" propagation="REQUIRED" /> 24 <tx:method name="create*" propagation="REQUIRED" /> 25 <tx:method name="delete*" propagation="REQUIRED" /> 26 <tx:method name="update*" propagation="REQUIRED" /> 27 <tx:method name="find*" propagation="SUPPORTS" read-only="true" /> 28 <tx:method name="select*" propagation="SUPPORTS" read-only="true" /> 29 <tx:method name="get*" propagation="SUPPORTS" read-only="true" /> 30 <tx:method name="query*" propagation="SUPPORTS" read-only="true" /> 31 </tx:attributes> 32 </tx:advice> 33 34 <!-- 切面 --> 35 <aop:config> 36 <aop:advisor advice-ref="txAdvice" 37 pointcut="execution(* cn.itcast.crm.service.*.*(..))" /> 38 </aop:config> 39 以上是关于SSM框架整合,以CRM为例子的主要内容,如果未能解决你的问题,请参考以下文章SSM框架整合Spring,SpringMVC,Mybatis