ssm整合

作者: 天空在微笑 | 来源:发表于2017-08-02 22:31 被阅读59次

    IDE:intellij
    构建工具:gradle
    框架:ssm

    整合配置也可以参考

    使用IDEA和gradle搭建Spring MVC和MyBatis开发环境

    也可以先按照spring开发环境配置配置一部分,然后接着按照下文配置,最终配置完成结构图 :

    最终配置完成结构图 image.png image.png

    下面是配置文件:
    web.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns="http://java.sun.com/xml/ns/javaee"
             xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
             id="WebApp_ID" version="2.5">
        <display-name>boot-crm</display-name>
        <welcome-file-list>
            <welcome-file>index.jsp</welcome-file>
        </welcome-file-list>
        <!-- Log4J 配置 Start -->
        <context-param>
            <param-name>log4jConfigLocation</param-name>
            <param-value>classpath:log4j.properties</param-value>
        </context-param>
        <context-param>
            <param-name>log4jRefreshInterval</param-name>
            <param-value>6000</param-value>
        </context-param>
        <!-- 配置spring -->
        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:config.service/applicationContext-*.xml;classpath:config.dao/applicationContext-*.xml;
            </param-value>
        </context-param>
    
        <!-- 配置监听器加载spring -->
        <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>
    
        <!-- 配置过滤器,解决post的乱码问题 -->
        <filter>
            <filter-name>encoding</filter-name>
            <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        </filter>
        <filter-mapping>
            <filter-name>encoding</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
    
        <!-- 配置SpringMVC -->
        <servlet>
            <servlet-name>boot-crm</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <init-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>classpath:config/controller/springmvc.xml</param-value>
            </init-param>
            <!-- 配置springmvc什么时候启动,参数必须为整数 -->
            <!-- 如果为0或者大于0,则springMVC随着容器启动而启动 -->
            <!-- 如果小于0,则在第一次请求进来的时候启动 -->
            <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>boot-crm</servlet-name>
            <!-- 所有的请求都进入springMVC -->
            <url-pattern>/</url-pattern>
        </servlet-mapping>
    </web-app>
    

    springmvc.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
           xmlns:context="http://www.springframework.org/schema/context"
           xmlns:mvc="http://www.springframework.org/schema/mvc"
           xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
            http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">
        <!-- 配置Controller扫描 -->
        <context:component-scan base-package="com.company.combine.controller" />
    
        <!--<mvc:default-servlet-handler />-->
        <!-- 配置注解驱动 -->
        <mvc:annotation-driven />
        <!-- 解决静态资源无法被springMVC处理的问题 -->
        <mvc:resources mapping="/css/**" location="WEB-INF/css/" />
        <mvc:resources mapping="/fonts/**" location="WEB-INF/fonts/" />
        <mvc:resources mapping="/js/**" location="WEB-INF/js/" />
        <!-- 配置视图解析器 -->
        <bean   class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <!-- 前缀 -->
            <property name="prefix" value="/WEB-INF/jsp/" />
            <!-- 后缀 -->
            <property name="suffix" value=".jsp" />
        </bean>
    </beans>
    

    applicationContext-dao.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
           xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
        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
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd">
    
        <!-- 配置 读取properties文件 jdbc.properties -->
        <context:property-placeholder location="classpath:jdbc.properties" />
    
        <!-- 配置 数据源 -->
        <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
            <property name="driverClassName" value="${jdbc.driver}" />
            <property name="url" value="${jdbc.url}" />
            <property name="username" value="${jdbc.username}" />
            <property name="password" value="${jdbc.password}" />
        </bean>
    
        <!-- 配置SqlSessionFactory -->
        <bean class="org.mybatis.spring.SqlSessionFactoryBean">
            <!-- 设置MyBatis核心配置文件 -->
            <property name="configLocation" value="classpath:config.dao/sqlMapConfig.xml" />
            <!-- 设置数据源 -->
            <property name="dataSource" ref="dataSource" />
        </bean>
    
        <!-- 配置Mapper扫描 -->
        <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
            <!-- 设置Mapper扫描包 -->
            <property name="basePackage" value="com.company.combine.mapper" />
        </bean>
    </beans>
    

    sqlMapConfig.xml

    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
            "http://mybatis.org/dtd/mybatis-3-config.dtd">
    <configuration>
    
    </configuration>
    

    config.service/applicationContext-service.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
           xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
        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
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd">
    
        <!-- 配置Service扫描 -->
        <context:component-scan base-package="com.company.combine.service" />
    </beans>
    

    config.service/applicationContext-trans.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
           xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
        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
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd">
    
        <!--<!– 事务管理器 –>-->
        <!--<bean id="transactionManager"   class="org.springframework.jdbc.datasource.DataSourceTransactionManager">-->
            <!--<!– 数据源 –>-->
            <!--<property name="dataSource" ref="dataSource" />-->
        <!--</bean>-->
    
        <!--<!– 通知 –>-->
        <!--<tx:advice id="txAdvice" transaction-manager="transactionManager">-->
            <!--<tx:attributes>-->
                <!--<!– 传播行为 –>-->
                <!--<tx:method name="save*" propagation="REQUIRED" />-->
                <!--<tx:method name="insert*" propagation="REQUIRED" />-->
                <!--<tx:method name="add*" propagation="REQUIRED" />-->
                <!--<tx:method name="create*" propagation="REQUIRED" />-->
                <!--<tx:method name="delete*" propagation="REQUIRED" />-->
                <!--<tx:method name="update*" propagation="REQUIRED" />-->
                <!--<tx:method name="find*" propagation="SUPPORTS" read-only="true" />-->
                <!--<tx:method name="select*" propagation="SUPPORTS" read-only="true" />-->
                <!--<tx:method name="get*" propagation="SUPPORTS" read-only="true" />-->
                <!--<tx:method name="query*" propagation="SUPPORTS" read-only="true" />-->
            <!--</tx:attributes>-->
        <!--</tx:advice>-->
    
        <!--<!– 切面 –>-->
        <!--<aop:config>-->
            <!--<aop:advisor advice-ref="txAdvice"-->
                         <!--pointcut="execution(* com.company.combine.service.*.*(..))" />-->
        <!--</aop:config>-->
    
    </beans>
    

    sql/crm.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');
    

    generateMapper.properties

    # 生成实体类所在的包
    package.model=com.company.combine.model
    # 生成 mapper 类所在的包
    package.mapper=com.company.combine.mapper
    # 生成 mapper xml 文件所在的包,默认存储在 resources 目录下
    package.xml=com.company.combine.mybatis_mapper
    

    generatorConfig.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE generatorConfiguration
            PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
            "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
    <generatorConfiguration>
        <context id="Mysql" targetRuntime="MyBatis3Simple" defaultModelType="flat">
            <commentGenerator>
                <property name="suppressAllComments" value="true"></property>
                <property name="suppressDate" value="true"></property>
                <property name="javaFileEncoding" value="utf-8"/>
            </commentGenerator>
    
            <jdbcConnection driverClass="${driverClass}"
                            connectionURL="${connectionURL}"
                            userId="${userId}"
                            password="${password}">
            </jdbcConnection>
    
            <javaTypeResolver>
                <property name="forceBigDecimals" value="false"/>
            </javaTypeResolver>
    
            <javaModelGenerator targetPackage="${modelPackage}" targetProject="${src_main_java}">
                <property name="enableSubPackages" value="true"></property>
                <property name="trimStrings" value="true"></property>
            </javaModelGenerator>
    
            <sqlMapGenerator targetPackage="${sqlMapperPackage}" targetProject="${src_main_resources}">
                <property name="enableSubPackages" value="true"></property>
            </sqlMapGenerator>
    
            <javaClientGenerator targetPackage="${mapperPackage}" targetProject="${src_main_java}" type="ANNOTATEDMAPPER">
                <property name="enableSubPackages" value="true"/>
            </javaClientGenerator>
    
            <!-- sql占位符,表示所有的表 -->
            <table tableName="%">
                <generatedKey column="epa_id" sqlStatement="Mysql" identity="true" />
            </table>
        </context>
    </generatorConfiguration>
    
    

    jdbc.properties

    jdbc.driver=com.mysql.jdbc.Driver
    jdbc.url=jdbc:mysql://localhost:3306/crm?characterEncoding=utf-8
    jdbc.username=root
    jdbc.password=root
    

    log4j.properties

    #定义LOG输出级别
    log4j.rootLogger=INFO,Console,File
    #定义日志输出目的地为控制台
    log4j.appender.Console=org.apache.log4j.ConsoleAppender
    log4j.appender.Console.Target=System.out
    #可以灵活地指定日志输出格式,下面一行是指定具体的格式
    log4j.appender.Console.layout = org.apache.log4j.PatternLayout
    log4j.appender.Console.layout.ConversionPattern=[%c] - %m%n
    
    #文件大小到达指定尺寸的时候产生一个新的文件
    log4j.appender.File = org.apache.log4j.RollingFileAppender
    #指定输出目录
    log4j.appender.File.File = logs/ssm.log
    #定义文件最大大小
    log4j.appender.File.MaxFileSize = 10MB
    # 输出所以日志,如果换成DEBUG表示输出DEBUG以上级别日志
    log4j.appender.File.Threshold = ALL
    log4j.appender.File.layout = org.apache.log4j.PatternLayout
    log4j.appender.File.layout.ConversionPattern =[%p] [%d{yyyy-MM-dd HH\:mm\:ss}][%c]%m%n
    

    build.gradle

    group 'com.company.combine'
    version '1.0-SNAPSHOT'
    
    apply plugin: 'java'
    apply plugin: 'war'
    apply plugin: 'groovy'
    apply plugin: 'idea'
    sourceCompatibility = 1.8
    
    repositories {
        maven{url 'http://maven.aliyun.com/nexus/content/groups/public'}
        mavenCentral()
    }
    configurations {
        mybatisGenerator
    }
    dependencies {
    
        testCompile group: 'junit', name: 'junit', version: '4.11'
        testCompile group: 'junit', name: 'junit', version: '4.12'
    
        // https://mvnrepository.com/artifact/org.mybatis.generator/mybatis-generator-core
        compile group: 'org.mybatis.generator', name: 'mybatis-generator-core', version: '1.3.5'
        // https://mvnrepository.com/artifact/tk.mybatis/mapper
        compile group: 'tk.mybatis', name: 'mapper', version: '3.4.2'
    // https://mvnrepository.com/artifact/mysql/mysql-connector-java
        compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.8'
    
        mybatisGenerator 'org.mybatis.generator:mybatis-generator-core:1.3.5'
        mybatisGenerator 'mysql:mysql-connector-java:5.1.8'
    }
    
    def getDbProperties = {
        def properties = new Properties()
        file("src/main/resources/jdbc.properties") .withInputStream {
            properties.load(it)
        }
        file("src/main/resources/generateMapper.properties").withInputStream {
            properties.load(it)
        }
        properties.each {
            project.extensions.add("$it.key",it.value)
        }
    }
    
    task mybatisGenerate << {
        def properties = getDbProperties()
    //    ant.properties['targetProject'] = projectDir.path
    //    ant.properties['driverClass'] = properties.getProperties("jdbc.driver")
    //    ant.properties['connectionURL'] = properties.getProperties("jdbc.url")
    //    ant.properties['userId'] = properties.getProperties("jdbc.username")
    //    ant.properties['password'] = properties.getProperties("jdbc.password")
    //    ant.properties['src_main_java'] = sourceSets.main.java.srcDirs[0].path
    //    ant.properties['src_main_resources'] = sourceSets.main.resources.srcDirs[0].path
    //    ant.properties['modelPackage'] = properties.getProperties("package.model")
    //    ant.properties['mapperPackage'] = properties.getProperties("package.mapper")
    //    ant.properties['sqlMapperPackage'] = properties.getProperties("package.xml")
    
        ant.properties['targetProject'] = projectDir.path
    //    ant.properties['jarDirection'] = project['jdbc.driver']
        ant.properties['driverClass'] = project['jdbc.driver']
        ant.properties['connectionURL'] = project['jdbc.url']
        ant.properties['userId'] = project['jdbc.username']
        ant.properties['password'] = project['jdbc.password']
        ant.properties['src_main_java'] = sourceSets.main.java.srcDirs[0].path
        ant.properties['src_main_resources'] = sourceSets.main.resources.srcDirs[0].path
        ant.properties['modelPackage'] = project['package.model']
        ant.properties['mapperPackage'] = project['package.mapper']
        ant.properties['sqlMapperPackage'] = project['package.xml']
        ant.taskdef(
                name: 'mbgenerator',
                classname: 'org.mybatis.generator.ant.GeneratorAntTask',
                classpath: configurations.mybatisGenerator.asPath
        )
        ant.mbgenerator(overwrite: true,
                configfile: 'src/main/resources/generatorConfig.xml', verbose: true) {
            propertyset {
                propertyref(name: 'targetProject')
                propertyref(name: 'userId')
                propertyref(name: 'driverClass')
                propertyref(name: 'connectionURL')
                propertyref(name: 'password')
                propertyref(name: 'src_main_java')
                propertyref(name: 'src_main_resources')
                propertyref(name: 'modelPackage')
                propertyref(name: 'mapperPackage')
                propertyref(name: 'sqlMapperPackage')
            }
        }
    }
    
    

    配置完成后点击右侧gradle,mybatisGenerate,如果执行出错,请在配置文件build.gradle中找到task
    mybatisGenerate,右键点击运行会给出错误信息


    image.png

    下面是代码文件:
    CustomerController.java

    package com.company.combine.controller;
    
    import com.company.combine.mapper.SysUserMapper;
    import com.company.combine.model.SysUser;
    import com.company.combine.service.CustomerServiceImpl;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Controller;
    import org.springframework.ui.Model;
    import org.springframework.web.bind.annotation.RequestMapping;
    
    /**
     * Created by liuqun on 2017/8/1.
     */
    @Controller
    @RequestMapping("customer")
    public class CustomerController {
    
    
        @Autowired
        CustomerServiceImpl customerService;
        /**
         * 显示用户列表
         *
         * @return
         */
        @RequestMapping("list")
        public String queryCustomerList(Model model) {
            SysUser sysUser = customerService.selectByPrimaryKey(5L);
            model.addAttribute("username", sysUser.getUserName());
            return "index1";
        }
    
    }
    
    

    CustomerServiceImpl .java

    package com.company.combine.service;
    
    import com.company.combine.mapper.SysUserMapper;
    import com.company.combine.model.SysUser;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;
    
    /**
     * Created by liuqun on 2017/8/1.
     */
    @Service
    public class CustomerServiceImpl {
    
        @Autowired
        private SysUserMapper sysUserMapper;
    
        public SysUser selectByPrimaryKey(Long key) {
            return sysUserMapper.selectByPrimaryKey(key);
        }
    
    }
    
    

    这个是自动生成的SysUserMapper.java

    package com.company.combine.mapper;
    
    import com.company.combine.model.SysUser;
    import java.util.List;
    import org.apache.ibatis.annotations.Delete;
    import org.apache.ibatis.annotations.Insert;
    import org.apache.ibatis.annotations.Result;
    import org.apache.ibatis.annotations.Results;
    import org.apache.ibatis.annotations.Select;
    import org.apache.ibatis.annotations.Update;
    import org.apache.ibatis.type.JdbcType;
    import org.springframework.stereotype.Repository;
    
    @Repository
    public interface SysUserMapper {
        @Delete({
            "delete from sys_user",
            "where user_id = #{userId,jdbcType=BIGINT}"
        })
        int deleteByPrimaryKey(Long userId);
    
        @Insert({
            "insert into sys_user (user_id, user_code, ",
            "user_name, user_password, ",
            "user_state)",
            "values (#{userId,jdbcType=BIGINT}, #{userCode,jdbcType=VARCHAR}, ",
            "#{userName,jdbcType=VARCHAR}, #{userPassword,jdbcType=VARCHAR}, ",
            "#{userState,jdbcType=CHAR})"
        })
        int insert(SysUser record);
    
        @Select({
            "select",
            "user_id, user_code, user_name, user_password, user_state",
            "from sys_user",
            "where user_id = #{userId,jdbcType=BIGINT}"
        })
        @Results({
            @Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT, id=true),
            @Result(column="user_code", property="userCode", jdbcType=JdbcType.VARCHAR),
            @Result(column="user_name", property="userName", jdbcType=JdbcType.VARCHAR),
            @Result(column="user_password", property="userPassword", jdbcType=JdbcType.VARCHAR),
            @Result(column="user_state", property="userState", jdbcType=JdbcType.CHAR)
        })
        SysUser selectByPrimaryKey(Long userId);
    
        @Select({
            "select",
            "user_id, user_code, user_name, user_password, user_state",
            "from sys_user"
        })
        @Results({
            @Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT, id=true),
            @Result(column="user_code", property="userCode", jdbcType=JdbcType.VARCHAR),
            @Result(column="user_name", property="userName", jdbcType=JdbcType.VARCHAR),
            @Result(column="user_password", property="userPassword", jdbcType=JdbcType.VARCHAR),
            @Result(column="user_state", property="userState", jdbcType=JdbcType.CHAR)
        })
        List<SysUser> selectAll();
    
        @Update({
            "update sys_user",
            "set user_code = #{userCode,jdbcType=VARCHAR},",
              "user_name = #{userName,jdbcType=VARCHAR},",
              "user_password = #{userPassword,jdbcType=VARCHAR},",
              "user_state = #{userState,jdbcType=CHAR}",
            "where user_id = #{userId,jdbcType=BIGINT}"
        })
        int updateByPrimaryKey(SysUser record);
    }
    

    index.jsp

    <%--
      Created by IntelliJ IDEA.
      User: liuqun
      Date: 2017/7/31
      Time: 21:59
      To change this template use File | Settings | File Templates.
    --%>
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <html>
      <head>
        <title>环境配置</title>
      </head>
      <body>
      SSM环境配置成功
      </body>
    </html>
    
    

    index1.jsp

    <%--
      Created by IntelliJ IDEA.
      User: liuqun
      Date: 2017/7/31
      Time: 21:59
      To change this template use File | Settings | File Templates.
    --%>
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <html>
      <head>
        <title>环境配置</title>
      </head>
      <body>
      ${username}
      </body>
    </html>
    
    

    数据库信息:

    image.png

    最后运行结果:

    image.png

    输入http://localhost:8080/customer/list运行结果

    image.png
    ssm配置完成已上传GitHub代码地址

    相关文章

      网友评论

        本文标题:ssm整合

        本文链接:https://www.haomeiwen.com/subject/qkcdlxtx.html