Spring mvc+Spring+hibernate整合

来源:互联网 发布:导出数据库命令 编辑:程序博客网 时间:2024/05/30 23:31

有段时间没有更新博客了,跟最近比较忙有关系。无聊搭建个Java web框架,反正好久没有自己搭建框架了,算是练练手了,今天我就来搭建一个框架,技术选型为spring mvc+Spring+hibernate。若想搭建Spring mvc+Spring+Mybatis请看我上篇日志,好了废话不多说,见代码。

1、开发环境:jdk1.7,tomcat6,eclipse版本过高需要设置jdk

2、项目结构


2、Spring mvc+Spring+Hibernate框架搭建流程跟Spring mvc+Spring+Mybatis搭建类似

首先在web.xml中配置Spring监听器及加载文件,其次配置spring mvc的配置,并在web.xml中配置spring mvc的servlet,最后在配置Spring与Hibernate整合部分即sessionFactory、数据库连接池等

3、先看web.xml配置

[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"  
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  4.     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee   
  5.     http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">  
  6.     <welcome-file-list>  
  7.         <welcome-file>index.jsp</welcome-file>  
  8.     </welcome-file-list>  
  9.   
  10. <!-- 加载spring配置文件 -->  
  11.     <context-param>  
  12.         <param-name>contextConfigLocation</param-name>  
  13.         <param-value>  
  14.             classpath:config/application-config.xml  
  15.         </param-value>  
  16.     </context-param>  
  17.   
  18. <!-- spring监听器 -->  
  19.     <listener>  
  20.         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  
  21.     </listener>  
  22. <!-- 配置编码 -->  
  23.     <filter>  
  24.         <filter-name>CharacterEncodingFilter</filter-name>  
  25.         <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>  
  26.         <init-param>  
  27.             <param-name>encoding</param-name>  
  28.             <param-value>UTF-8</param-value>  
  29.         </init-param>  
  30.         <init-param>  
  31.             <param-name>forceEncoding</param-name>  
  32.             <param-value>true</param-value>  
  33.         </init-param>  
  34.     </filter>  
  35.     <filter-mapping>  
  36.         <filter-name>CharacterEncodingFilter</filter-name>  
  37.         <url-pattern>/*</url-pattern>  
  38.     </filter-mapping>  
  39.   
  40.   
  41.     <!-- spring mvc dispatcher -->  
  42.     <servlet>  
  43.         <servlet-name>dispatcherServlet</servlet-name>  
  44.         <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>  
  45.         <init-param>  
  46.             <param-name>contextConfigLocation</param-name>  
  47.             <param-value>classpath:config/mvc-config.xml</param-value>  
  48.         </init-param>  
  49.         <load-on-startup>1</load-on-startup>  
  50.     </servlet>  
  51.   
  52.     <servlet-mapping>  
  53.         <servlet-name>dispatcherServlet</servlet-name>  
  54.         <url-pattern>/</url-pattern>  
  55.     </servlet-mapping>  
  56. <!--错误页面配置 -->  
  57.     <error-page>  
  58.         <error-code>403</error-code>  
  59.         <location>/WEB-INF/view/error/403.jsp</location>  
  60.     </error-page>  
  61.     <error-page>  
  62.         <error-code>404</error-code>  
  63.         <location>/WEB-INF/view/error/404.jsp</location>  
  64.     </error-page>  
  65.     <error-page>  
  66.         <error-code>500</error-code>  
  67.         <location>/WEB-INF/view/error/500.jsp</location>  
  68.     </error-page>   
  69. </web-app>  
4、我们在来看看spring mvc的配置文件mvc-config.xml

[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2.   
  3. <beans xmlns="http://www.springframework.org/schema/beans"  
  4.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"  
  5.     xmlns:context="http://www.springframework.org/schema/context"  
  6.     xmlns:p="http://www.springframework.org/schema/p"  
  7.     xsi:schemaLocation="http://www.springframework.org/schema/mvc  
  8.        http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd  
  9.         http://www.springframework.org/schema/beans  
  10.         http://www.springframework.org/schema/beans/spring-beans.xsd   
  11.         http://www.springframework.org/schema/context   
  12.         http://www.springframework.org/schema/context/spring-context.xsd" default-autowire="byType">  
  13.   
  14. <!-- 启动注解 -->  
  15.     <mvc:annotation-driven />   
  16. <!-- 扫描注解包 -->  
  17.     <context:component-scan base-package="com.demo"></context:component-scan>  
  18. <!-- 配置view页面 -->  
  19.     <bean  
  20.         class="org.springframework.web.servlet.view.InternalResourceViewResolver">  
  21.         <property name="prefix" value="/WEB-INF/view/" />  
  22.         <property name="suffix" value=".jsp" />  
  23.     </bean>  
  24. <!-- 加载application.properties文件,这个文件一般都配置了数据库及数据库连接池等 -->  
  25.     <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer">    
  26.         <property name="location">    
  27.         <value>classpath:config/application.properties</value>    
  28.         </property>    
  29.     </bean>    
  30.     <!-- 静态文件 -->  
  31.     <mvc:resources mapping="/resources/**" location="/WEB-INF/resources/"></mvc:resources>  
  32. </beans>  

[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1.   
5、常用配置信息如数据库连接池等信息,一般习惯配置在新的文件中application.properties
[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. #hibernate  
  2. hibernate.max_fetch_depth=3  
  3. hibernate.jdbc.fetch_size=50  
  4. hibernate.jdbc.batch_size=10  
  5. hibernate.show_sql=true  
  6. hibernate.cache.use_second_level_cache=true  
  7. hibernate.cache.use_query_cache=true  
  8. hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFactory  
  9.   
  10. jdbc.driverClassName=com.mysql.jdbc.Driver  
  11. jdbc.url=jdbc:mysql://localhost:3306/demo?useUnicode=true&characterEncoding=UTF-8  
  12. jdbc.username=root  
  13. jdbc.password=root  
  14. jdbc.maxActive=50  
  15.   
  16. c3p0.acquireIncrement=10  
  17. c3p0.minPoolSize=3  
  18. c3p0.maxPoolSize=200  
  19. c3p0.maxIdleTime=6000  
6、spring基本配置,及spring 事物数据库连接池等配置
基本配置application-config.xml

[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  4.        xmlns:context="http://www.springframework.org/schema/context"  
  5.        xmlns:task="http://www.springframework.org/schema/task"  
  6.        xmlns:cache="http://www.springframework.org/schema/cache"  
  7.        xmlns:p="http://www.springframework.org/schema/p"  
  8.        xsi:schemaLocation="http://www.springframework.org/schema/beans  
  9.         http://www.springframework.org/schema/beans/spring-beans.xsd  
  10.         http://www.springframework.org/schema/context  
  11.         http://www.springframework.org/schema/context/spring-context.xsd  
  12.         http://www.springframework.org/schema/task  
  13.         http://www.springframework.org/schema/task/spring-task.xsd  
  14.         http://www.springframework.org/schema/cache  
  15.         http://www.springframework.org/schema/cache/spring-cache.xsd">  
  16.   
  17.       
  18.     <!-- 扫描包 -->  
  19.     <context:component-scan base-package="com.demo"/>  
  20. <!-- 注解配置 -->  
  21.     <context:annotation-config></context:annotation-config>  
  22.     <!-- 引人其他文件 -->  
  23.      <import resource="data-source-tx.xml"></import>  
  24.       
  25.      <!-- hibernate ehcache   
  26.     <cache:annotation-driven cache-manager="cacheManager"></cache:annotation-driven>  
  27.       
  28.      <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">  
  29.         <property name="cacheManager" ref="ehcache"></property>  
  30.     </bean>  
  31.     <bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"  
  32.           p:configLocation="classpath:config/ehcache.xml" p:shared="true"/>-->  
  33.   
  34. </beans>  
hibernate的sessionFactory及数据库连接池配置datasource-tx.xml
[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
  4.     xmlns:context="http://www.springframework.org/schema/context"  
  5.     xmlns:jdbc="http://www.springframework.org/schema/jdbc"   
  6.     xmlns:tx="http://www.springframework.org/schema/tx"  
  7.     xmlns:aop="http://www.springframework.org/schema/aop"  
  8.     xmlns:p="http://www.springframework.org/schema/p"  
  9.     xsi:schemaLocation="http://www.springframework.org/schema/jdbc  
  10.         http://www.springframework.org/schema/jdbc/spring-jdbc.xsd  
  11.         http://www.springframework.org/schema/beans   
  12.         http://www.springframework.org/schema/beans/spring-beans.xsd  
  13.         http://www.springframework.org/schema/tx   
  14.         http://www.springframework.org/schema/tx/spring-tx.xsd  
  15.         http://www.springframework.org/schema/aop  
  16.         http://www.springframework.org/schema/aop/spring-aop-4.0.xsd  
  17.         http://www.springframework.org/schema/context   
  18.         http://www.springframework.org/schema/context/spring-context.xsd">  
  19.   
  20.     <context:property-placeholder location="classpath:config/application.properties"/>  
  21.   
  22.     <!-- sessionFactory -->  
  23.     <bean id="sessionFactory"   
  24.         class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">  
  25.         <property name="dataSource" ref="dataSource" />  
  26.         <property name="packagesToScan" value="com.demo.model" />  
  27.         <property name="hibernateProperties">  
  28.             <props>  
  29.                 <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>  
  30.                 <prop key="hibernate.current_session_context_class">thread</prop>   
  31.             </props>  
  32.         </property>  
  33.     </bean>  
  34.   
  35.     <!-- dataSource -->  
  36.     <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"  
  37.         destroy-method="close">  
  38.         <property name="driverClass" value="${jdbc.driverClassName}" />  
  39.         <property name="jdbcUrl" value="${jdbc.url}" />  
  40.         <property name="user" value="${jdbc.username}" />  
  41.         <property name="password" value="${jdbc.password}" />  
  42.   
  43.         <!-- these are C3P0 properties -->  
  44.         <property name="acquireIncrement" value="${c3p0.acquireIncrement}" />  
  45.         <property name="minPoolSize" value="${c3p0.minPoolSize}" />  
  46.         <property name="maxPoolSize" value="${c3p0.maxPoolSize}" />  
  47.         <property name="maxIdleTime" value="${c3p0.maxIdleTime}" />  
  48.     </bean>  
  49.       
  50.     <!-- 配置Hibernate事务管理器 -->  
  51.     <bean id="transactionManager"  
  52.         class="org.springframework.orm.hibernate4.HibernateTransactionManager">  
  53.       <property name="sessionFactory" ref="sessionFactory" />  
  54.    </bean>  
  55.    <!-- 事物注解配置 -->  
  56.    <tx:annotation-driven transaction-manager="transactionManager"/>      
  57.          
  58.   
  59. </beans>  

以上内容为配置内容,配置讲完了,下面以用户登录为测试案例

1、控制层controller

[java] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. package com.demo.controller;  
  2.   
  3. import javax.validation.Valid;  
  4.   
  5. import org.springframework.beans.factory.annotation.Autowired;  
  6. import org.springframework.stereotype.Controller;  
  7. import org.springframework.ui.Model;  
  8. import org.springframework.validation.BindingResult;  
  9. import org.springframework.web.bind.annotation.RequestMapping;  
  10. import org.springframework.web.bind.annotation.RequestMethod;  
  11.   
  12. import com.demo.model.User;  
  13. import com.demo.service.UserService;  
  14.   
  15. @Controller  
  16. @RequestMapping("/user")  
  17. public class UserController {  
  18.       
  19.     @Autowired  
  20.     private UserService userService;  
  21.       
  22.     @RequestMapping(value="/login",method=RequestMethod.GET,params="form")  
  23.     public String toLogin(Model model){  
  24.         User user = new User();  
  25.         model.addAttribute(user);  
  26.         return "user/login";  
  27.     }  
  28.       
  29.     @RequestMapping(value="/login",method=RequestMethod.POST)  
  30.     public String login(@Valid User user,BindingResult result){  
  31.         if(result.hasErrors()){  
  32.             return "user/login";  
  33.         }  
  34.         if(this.userService.login(user.getUsername(), user.getPassword())){  
  35.             return "user/success";  
  36.         }  
  37.         return "user/fail";  
  38.           
  39.     }  
  40.   
  41. }  
2、实体层model

[java] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. package com.demo.model;  
  2.   
  3. import java.io.Serializable;  
  4.   
  5. import javax.persistence.Entity;  
  6. import javax.persistence.GeneratedValue;  
  7. import javax.persistence.Id;  
  8. import javax.persistence.Table;  
  9.   
  10. @Entity  
  11. @Table(name="user")  
  12. public class User implements Serializable {  
  13.   
  14.     /** 
  15.      *  
  16.      */  
  17.     private static final long serialVersionUID = 1482055695347272535L;  
  18.       
  19.     @Id  
  20.     @GeneratedValue  
  21.     private long id;  
  22.       
  23.     private String username;  
  24.       
  25.     private String password;  
  26.   
  27.     public long getId() {  
  28.         return id;  
  29.     }  
  30.   
  31.     public void setId(long id) {  
  32.         this.id = id;  
  33.     }  
  34.   
  35.     public String getUsername() {  
  36.         return username;  
  37.     }  
  38.   
  39.     public void setUsername(String username) {  
  40.         this.username = username;  
  41.     }  
  42.   
  43.     public String getPassword() {  
  44.         return password;  
  45.     }  
  46.   
  47.     public void setPassword(String password) {  
  48.         this.password = password;  
  49.     }  
  50.       
  51.       
  52.   
  53. }  

3、服务层service

服务层接口

[java] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. package com.demo.service;  
  2.   
  3. public interface UserService {  
  4.       
  5.     public boolean login(String username,String password);  
  6.   
  7. }  
服务层实现类
[java] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. package com.demo.service.impl;  
  2.   
  3. import javax.transaction.Transactional;  
  4.   
  5. import org.springframework.beans.factory.annotation.Autowired;  
  6. import org.springframework.stereotype.Service;  
  7.   
  8. import com.demo.dao.UserDao;  
  9. import com.demo.model.User;  
  10. import com.demo.service.UserService;  
  11.   
  12. @Service  
  13. @Transactional  
  14. public class UserServiceImpl implements UserService {  
  15.       
  16.     @Autowired  
  17.     private UserDao userDao;  
  18.   
  19.     @Override  
  20.     @Transactional  
  21.     public boolean login(String username, String password) {  
  22.         boolean flag = false;  
  23.         User user = this.userDao.findByUsernameAndPassword(username, password);  
  24.         if(user != null){  
  25.             if(username.equals(user.getUsername()) && password.equals(user.getPassword())){  
  26.                 flag = true;  
  27.             }  
  28.         }  
  29.         return flag;  
  30.     }  
  31.   
  32. }  
4、持久层dao
[java] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. package com.demo.dao;  
  2.   
  3. import org.hibernate.Query;  
  4. import org.hibernate.Session;  
  5. import org.hibernate.SessionFactory;  
  6. import org.springframework.beans.factory.annotation.Autowired;  
  7. import org.springframework.stereotype.Repository;  
  8.   
  9. import com.demo.model.User;  
  10. @Repository  
  11. public class UserDao{  
  12.       
  13.     @Autowired  
  14.     private SessionFactory sessionFactory;  
  15.       
  16.     public Session getSession(){  
  17.         return this.sessionFactory.openSession();  
  18.     }  
  19.       
  20.     public void close(Session session){  
  21.         if(session != null)  
  22.             session.close();  
  23.     }  
  24.           
  25.     public User findByUsernameAndPassword(String username,String password){  
  26.         String hsql="from User u where u.username= :username and u.password= :password";  
  27.         Session session = getSession();  
  28.         Query query = session.createQuery(hsql);  
  29.         query.setParameter("username", username).setParameter("password", password);  
  30.         User user = (User) query.uniqueResult();  
  31.         close(session);  
  32.         return user;  
  33.     }  
  34.   
  35. }  
5、sql脚本
[sql] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. /*  
  2. Navicat MySQL Data Transfer  
  3.   
  4. Source Server         : localhost  
  5. Source Server Version : 50622  
  6. Source Host           : localhost:3306  
  7. Source Database       : demo  
  8.   
  9. Target Server Type    : MYSQL  
  10. Target Server Version : 50622  
  11. File Encoding         : 65001  
  12.   
  13. Date: 2016-07-19 20:36:51  
  14. */  
  15.   
  16. SET FOREIGN_KEY_CHECKS=0;  
  17.   
  18. -- ----------------------------  
  19. -- Table structure for `kpi`  
  20. -- ----------------------------  
  21. DROP TABLE IF EXISTS `kpi`;  
  22. CREATE TABLE `kpi` (  
  23.   `id` int(11) NOT NULL AUTO_INCREMENT,  
  24.   `dayvarchar(20) DEFAULT NULL,  
  25.   `state` varchar(20) DEFAULT NULL,  
  26.   `num` int(111) DEFAULT NULL,  
  27.   PRIMARY KEY (`id`)  
  28. ) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8;  
  29.   
  30. -- ----------------------------  
  31. -- Records of kpi  
  32. -- ----------------------------  
  33. INSERT INTO `kpi` VALUES ('1''6月28日''success''11');  
  34. INSERT INTO `kpi` VALUES ('2''6月28日''fail''22');  
  35. INSERT INTO `kpi` VALUES ('3''6月29日''success''33');  
  36. INSERT INTO `kpi` VALUES ('4''6月29日''fail''27');  
  37. INSERT INTO `kpi` VALUES ('5''6月30日''success''232');  
  38. INSERT INTO `kpi` VALUES ('6''6月30日''fail''123');  
  39. INSERT INTO `kpi` VALUES ('7''7月1日''success''235');  
  40. INSERT INTO `kpi` VALUES ('8''7月1日''fail''80');  
  41. INSERT INTO `kpi` VALUES ('9''7月2日''success''90');  
  42. INSERT INTO `kpi` VALUES ('10''7月2日''fail''324');  
  43. INSERT INTO `kpi` VALUES ('11''7月3日''success''325');  
  44. INSERT INTO `kpi` VALUES ('12''7月3日''fail''134');  
  45. INSERT INTO `kpi` VALUES ('13''7月4日''success''345');  
  46. INSERT INTO `kpi` VALUES ('14''7月4日''fail''245');  
  47. INSERT INTO `kpi` VALUES ('15''7月5日''success''124');  
  48. INSERT INTO `kpi` VALUES ('16''7月5日''fail''256');  
  49. INSERT INTO `kpi` VALUES ('17''7月6日''success''193');  
  50. INSERT INTO `kpi` VALUES ('18''7月6日''fail''274');  
  51. INSERT INTO `kpi` VALUES ('19''7月7日''success''232');  
  52. INSERT INTO `kpi` VALUES ('20''7月7日''fail''234');  
  53.   
  54. -- ----------------------------  
  55. -- Table structure for `kpi_detail`  
  56. -- ----------------------------  
  57. DROP TABLE IF EXISTS `kpi_detail`;  
  58. CREATE TABLE `kpi_detail` (  
  59.   `id` int(11) NOT NULL AUTO_INCREMENT,  
  60.   `startTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,  
  61.   `endTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,  
  62.   `state` varchar(20) DEFAULT NULL,  
  63.   PRIMARY KEY (`id`)  
  64. ) ENGINE=InnoDB AUTO_INCREMENT=41 DEFAULT CHARSET=utf8;  
  65.   
  66. -- ----------------------------  
  67. -- Records of kpi_detail  
  68. -- ----------------------------  
  69. INSERT INTO `kpi_detail` VALUES ('1''2016-07-17 16:02:19''2016-07-17 16:02:19''success');  
  70. INSERT INTO `kpi_detail` VALUES ('2''2016-07-17 16:03:27''2016-07-17 16:03:27''success');  
  71. INSERT INTO `kpi_detail` VALUES ('3''2016-07-17 16:03:27''2016-07-17 16:03:27''success');  
  72. INSERT INTO `kpi_detail` VALUES ('4''2016-07-17 16:03:27''2016-07-17 16:03:27''success');  
  73. INSERT INTO `kpi_detail` VALUES ('6''2016-07-17 16:03:28''2016-07-17 16:03:28''success');  
  74. INSERT INTO `kpi_detail` VALUES ('7''2016-07-17 16:03:28''2016-07-17 16:03:28''success');  
  75. INSERT INTO `kpi_detail` VALUES ('8''2016-07-17 16:03:28''2016-07-17 16:03:28''success');  
  76. INSERT INTO `kpi_detail` VALUES ('9''2016-07-17 16:03:28''2016-07-17 16:03:28''success');  
  77. INSERT INTO `kpi_detail` VALUES ('13''2016-07-17 16:03:28''2016-07-17 16:03:28''success');  
  78. INSERT INTO `kpi_detail` VALUES ('14''2016-07-17 16:03:28''2016-07-17 16:03:28''success');  
  79. INSERT INTO `kpi_detail` VALUES ('15''2016-07-17 16:03:28''2016-07-17 16:03:28''success');  
  80. INSERT INTO `kpi_detail` VALUES ('16''2016-07-17 16:03:28''2016-07-17 16:03:28''success');  
  81. INSERT INTO `kpi_detail` VALUES ('17''2016-07-17 16:03:28''2016-07-17 16:03:28''success');  
  82. INSERT INTO `kpi_detail` VALUES ('18''2016-07-17 16:03:28''2016-07-17 16:03:28''success');  
  83. INSERT INTO `kpi_detail` VALUES ('19''2016-07-17 16:03:28''2016-07-17 16:03:28''success');  
  84. INSERT INTO `kpi_detail` VALUES ('20''2016-07-17 16:03:28''2016-07-17 16:03:28''success');  
  85. INSERT INTO `kpi_detail` VALUES ('28''2016-07-17 16:03:28''2016-07-17 16:03:28''success');  
  86. INSERT INTO `kpi_detail` VALUES ('29''2016-07-17 16:03:28''2016-07-17 16:03:28''success');  
  87. INSERT INTO `kpi_detail` VALUES ('30''2016-07-17 16:03:28''2016-07-17 16:03:28''success');  
  88. INSERT INTO `kpi_detail` VALUES ('31''2016-07-17 16:03:28''2016-07-17 16:03:28''success');  
  89. INSERT INTO `kpi_detail` VALUES ('32''2016-07-17 16:03:28''2016-07-17 16:03:28''success');  
  90. INSERT INTO `kpi_detail` VALUES ('33''2016-07-17 16:03:28''2016-07-17 16:03:28''success');  
  91. INSERT INTO `kpi_detail` VALUES ('34''2016-07-17 16:03:28''2016-07-17 16:03:28''success');  
  92. INSERT INTO `kpi_detail` VALUES ('35''2016-07-17 16:03:28''2016-07-17 16:03:28''success');  
  93. INSERT INTO `kpi_detail` VALUES ('36''2016-07-17 16:03:28''2016-07-17 16:03:28''success');  
  94. INSERT INTO `kpi_detail` VALUES ('37''2016-07-17 16:03:28''2016-07-17 16:03:28''success');  
  95. INSERT INTO `kpi_detail` VALUES ('38''2016-07-17 16:03:28''2016-07-17 16:03:28''success');  
  96. INSERT INTO `kpi_detail` VALUES ('39''2016-07-17 16:03:28''2016-07-17 16:03:28''success');  
  97. INSERT INTO `kpi_detail` VALUES ('40''2016-07-17 16:03:28''2016-07-17 16:03:28''success');  
  98.   
  99. -- ----------------------------  
  100. -- Table structure for `user`  
  101. -- ----------------------------  
  102. DROP TABLE IF EXISTS `user`;  
  103. CREATE TABLE `user` (  
  104.   `id` int(11) NOT NULL AUTO_INCREMENT,  
  105.   `username` varchar(255) DEFAULT NULL,  
  106.   `passwordvarchar(255) DEFAULT NULL,  
  107.   PRIMARY KEY (`id`)  
  108. ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;  
  109.   
  110. -- ----------------------------  
  111. -- Records of user  
  112. -- ----------------------------  
  113. INSERT INTO `userVALUES ('1''samtest''123456');  
至此,整个项目算是搭建并测试成功
0 0
原创粉丝点击