步骤一:数据库连接文件

 jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/school_o2o?useUnicode=true&characterEncoding=utf8
jdbc.username=root
jdbc.password=

步骤二:MyBatis的配置

<?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>
<settings>
<setting name="useGeneratedKeys" value="true" />
<!--列标签 替换 列别名 -->
<setting name="useColumnLabel" value="true" />
<setting name="mapUnderscoreToCamelCase" value="true" />
</settings>
</configuration>

http://www.mybatis.org/mybatis-3/zh/configuration.html#settings

步骤三:Spring-dao.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:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<!-- 配置整合mybatis过程 -->
<!-- .配置数据库相关参数properties的属性 ${url} -->
<context:property-placeholder location="classpath:jdbc.properties"/> <!-- .配置数据库连接池 -->
<bean id="dataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource">
<!-- 配置连接池属性 -->
<property name="driverClass" value="${jdbc.driver}" />
<property name="jdbcUrl" value="${jdbc.url}" />
<property name="user" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" /> <!-- c3p0连接池的私有属性 -->
<property name="maxPoolSize" value="" />
<property name="minPoolSize" value="" />
<!-- 关闭连接后不自动commit -->
<property name="autoCommitOnClose" value="false" />
<!-- 获取连接超时时间 -->
<property name="checkoutTimeout" value="" />
<!-- 当获取连接失败重试次数 -->
<property name="acquireRetryAttempts" value="" />
</bean> <!-- .配置SqlSessionFactory对象 -->
<bean id="sqlSessionFactory"
class="org.mybatis.spring.SqlSessionFactoryBean">
<!-- 注入数据库连接池 -->
<property name="dataSource" ref="dataSource" />
<!-- 配置MyBaties全局配置文件:mybatis-config.xml -->
<property name="configLocation"
value="classpath:mybatis-config.xml" />
<!-- 扫描bean包 使用别名 -->
<property name="typeAliasesPackage"
value="com.figsprit.o2o.bean" />
<!-- 扫描sql配置文件:mapper需要的xml文件 -->
<property name="mapperLocations"
value="classpath:mapper/*.xml" />
</bean> <!-- .配置扫描Dao接口包,动态实现Dao接口,注入到spring容器中 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<!-- 注入sqlSessionFactory -->
<property name="sqlSessionFactoryBeanName"
value="sqlSessionFactory" />
<!-- 给出需要扫描Dao接口包 -->
<property name="basePackage" value="com.figsprite.o2o.dao" />
</bean>
</beans>

步骤四:Spring-service.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:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
<!-- 扫描service包下所有使用注解的类型 -->
<context:component-scan base-package="com.figsprite.o2o.service" /> <!-- 配置事务管理器 -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<!-- 注入数据库连接池 -->
<property name="dataSource" ref="dataSource" />
</bean> <!-- 配置基于注解的声明式事务 -->
<tx:annotation-driven transaction-manager="transactionManager" />
</beans>

步骤五:Spring-web.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: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.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">
<!-- 配置SpringMVC -->
<!-- .开启SpringMVC注解模式 -->
<!-- 简化配置: ()自动注册DefaultAnootationHandlerMapping,AnotationMethodHandlerAdapter
()提供一些列:数据绑定,数字和日期的format @NumberFormat, @DateTimeFormat, xml,json默认读写支持 -->
<mvc:annotation-driven /> <!-- .静态资源默认servlet配置 ()加入对静态资源的处理:js,gif,png ()允许使用"/"做整体映射 -->
<mvc:resources mapping="/resources/**" location="/resources/" />
<mvc:default-servlet-handler /> <!-- .定义视图解析器 -->
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/html/"></property>
<property name="suffix" value=".html"></property>
</bean> <!-- .扫描web相关的bean -->
<context:component-scan base-package="com.figsprite.o2o.web" /> </beans>

步骤六:web.xml配置

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1" metadata-complete="true">
<display-name>My O2O</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list> <servlet>
<servlet-name>spring-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/spring-*.xml</param-value>
</init-param>
</servlet> <servlet-mapping>
<servlet-name>spring-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>

  

  今后有空再回来把每个标签解释一下,今天先这个样子简单处理一下(๑Ő௰Ő๑)

最新文章

  1. 写JQuery 插件 什么?你还不会写JQuery 插件
  2. 为什么没有MMU的处理器无法安装操作系统?
  3. VS2010打开项目时,出现“已经在解决方案中打开了具有该名称的项目”问题的解决方案
  4. codeforces 455B A Lot of Games(博弈,字典树)
  5. 在windows2003系统上安装两个版本的oracle
  6. 【转】linux下 postgres的一些操作总结
  7. 《SAS编程和数据挖掘商业案例》学习笔记# 19
  8. 一、Hadoop基本操作命令
  9. instr函数的&quot;重载&quot;
  10. js判断flash文件是否加载完毕
  11. 广州.NET微软技术俱乐部休闲活动 - 每周三五晚周日下午爬白云山活动
  12. css_属性
  13. 使用SSH的scp命令行传输文件到远程服务器
  14. Linux虚拟内存(swap)调优篇-“swappiness”,“vm.dirty_background_ratio”和“vm.dirty_ratio”
  15. leecode第五十四题(螺旋矩阵)
  16. 突破本地离线存储5M限制的JS库localforage简介
  17. zookeeper 图形化的客户端工具:ZooInspector
  18. c#编写windows服务在开机是OnStart启动超时
  19. Autowired使用说明
  20. 01:MFC应用程序编程

热门文章

  1. Loj 3058. 「HNOI2019」白兔之舞
  2. [Python] Python 100例
  3. sql优化的几种方法
  4. javascript中数组化的一般见解
  5. ESP8266串口和MQTT服务器消息互传(版本一) 单纯透传+保存WIFI账号信息
  6. 【转】从零开始玩转logback
  7. Golang 学习资料
  8. Python排序算法——选择排序
  9. 在Ubuntu上快速搭建基于Beego的RESTful API
  10. ODPS-Java-SDK快速入门