>### 1.编写spring的配置文件applicationContext.xml
步骤:
- 1.只扫描 Service Repository Component
- 2.配置外部的数据源文件位置 db.properties
~~~
jdbcUrl=jdbc:mysql://localhost:3306/ssm
driverClass=com.mysql.jdbc.Driver
user=root
password=root
~~~
- 3.c3p0数据库连接池
- 4.配置和mybatis的整合(sqlSessionFactoryBean) 指定三个属性①.总的配置文件的位置 ②.指定数据源 ③.指定所有mapper映射文件的位置
- 5.配置扫描器(MapperScannerConfigurer),将dao的实现加入到ioc容器
- 6.配置一个可以执行批量的sqlSession(可选,主要用于测试插入数据,很多条数据)
- 7.配置事务 aop切面
~~~
<?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:aop="http://www.springframework.org/schema/aop"
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/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
<!-- 配置需要扫描的注解,都交给springIOC容器来统一管理
spring @Service @Repository @Component -->
<context:component-scan base-package="cn.li">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
<!-- spring的配置文件,这里主要配置和业务逻辑有关的 -->
<!-- =========数据源 事务控制 xxx======== -->
<context:property-placeholder location="classpath:db.properties"/>
<!-- c3p0数据库连接池 -->
<bean id="pooledDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="jdbcUrl" value="${jdbcUrl}"></property>
<property name="driverClass" value="${driverClass}"></property>
<property name="user" value="${user}"></property>
<property name="password" value="${password}"></property>
</bean>
<!-- ==========配置和MyBatis的整合======== -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<!-- 指定mybatis全局配置文件的位置 -->
<property name="configLocation" value="classpath:mybatis-config.xml"></property>
<property name="dataSource" ref="pooledDataSource"></property>
<!-- 指定mybatis,mapper文件的位置 -->
<property name="mapperLocations" value="classpath:mapper/*.xml"></property>
</bean>
<!--配置扫描器,将mybatis接口的实现加入到ioc容器中 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<!--扫描所有dao接口的实现,加入到ioc容器中 -->
<property name="basePackage" value="cn.li.crud.dao"></property>
</bean>
<!-- 配置一个可以执行批量的sqlSession -->
<bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg name="sqlSessionFactory" ref="sqlSessionFactory"></constructor-arg>
<constructor-arg name="executorType" value="BATCH"></constructor-arg>
</bean>
<!-- ===============事务控制的配置 ================-->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<!--控制住数据源 -->
<property name="dataSource" ref="pooledDataSource"></property>
</bean>
<!--开启基于注解的事务,使用xml配置形式的事务(必要主要的都是使用配置式) -->
<aop:config>
<!-- 切入点表达式 -->
<aop:pointcut expression="execution(* cn.li.crud.service..*(..))" id="txPoint"/>
<!-- 配置事务增强 -->
<aop:advisor advice-ref="txAdvice" pointcut-ref="txPoint"/>
</aop:config>
<!--配置事务增强,事务如何切入 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<!-- 所有方法都是事务方法 -->
<tx:method name="*"/>
<!--以get开始的所有方法 -->
<tx:method name="get*" read-only="true"/>
</tx:attributes>
</tx:advice>
<!-- Spring配置文件的核心点(数据源、与mybatis的整合,事务控制) -->
</beans>
~~~
>### 2.编写springmvc的配置文件dispatcherServlet-servlet.xml,放在WEN-INF目录下

步骤:
- 1.springMVC的配置文件,包含网站跳转逻辑的控制,配置,只扫描控制器
- 2.配置视图解析器
- 3.两个标准配置
~~~
<?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/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd">
<!-- springMVC的配置文件,包含网站跳转逻辑的控制,配置 -->
<context:component-scan base-package="cn.li"
use-default-filters="false">
<!-- 只扫描控制器 -->
<context:include-filter type="annotation"
expression="org.springframework.stereotype.Controller" />
</context:component-scan>
<!-- 配置视图解析器,方便页面返回 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
<!-- 两个标准配置 -->
<!-- 将springmvc不能处理的请求交给tomcat -->
<mvc:default-servlet-handler/>
<!-- 能支持springmvc更高级的一些功能,JSR303校验,快捷的ajax...映射动态请求 -->
<mvc:annotation-driven/>
</beans>
~~~
>### 3.编写mybatis的配置文件mybatis-config.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>
<settings>
<!-- 开启驼峰命名规则 。。。 -->
<setting name="mapUnderscoreToCamelCase" value="true" />
</settings>
<typeAliases>
<!-- 批量注册别名。 -->
<package name="cn.li.crud.bean" />
</typeAliases>
<plugins>
<plugin interceptor="com.github.pagehelper.PageInterceptor">
<!--分页参数合理化 -->
<property name="reasonable" value="true" />
</plugin>
</plugins>
</configuration>
~~~
- spring
- 1.spring第一天
- 1.1 安装spring插件(spring tool suite)
- 1.2 spring概述
- 1.3 控制反转&依赖注入
- 1.4 springIOC容器
- 1.5 依赖注入的四种方式
- 1.6 配置bean的细节
- 1.7 bean之间的关系
- 1.8 bean作用域
- 1.9 补充:创建对象的几种方法
- 1源代码位置
- 2.spring第二天
- 2.1 使用外部属性文件
- 2.2 spEL
- 2.3 bean的生命周期
- 2.4 通过工厂方式配置bean
- 2.5 基于注解的方式配置bean
- 2.6 组件装配
- 2.7 静态代理
- 2.8 动态代理
- 2.9 Cglib代理
- 2源代码位置
- 3. spring第三天
- 3.1 springAOP
- 3.1.1 AOP简介
- 3.1.2 为什么使用AOP
- 3.1.3 AOP关键术语
- 3.1.4 AOP图解
- 3.1.5 springAOP实现步骤
- 3.1.6 SpringAOP实现原理:
- 3.1.7 AOP的好处
- 3.1.8 AOP在实际项目中的主要应用
- 3代码地址
- 3.1.9 纯注解版配置aop的方式
- 3.2 maven环境搭建
- 附IDEA激活码
- 4. spring第四天
- 4.1 c3p0事务
- 4.2 命令窗口事务
- 4.3 c3p0连接池设置
- 4.4 事务中的一些基本概念
- 4.5 事务的传播行为
- 4.6 自定义异常
- 4.7 spring整合Junit单元测试
- 4.8 JdbcTemplate(附源代码)
- 事务源代码
- 4.9 纯注解tx
- 4.10 基于xml配置事务
- 0. jsp页面修改编码方式
- 0.1 eclipse配置tomcat
- 0.单例模式-饱汉模式
- 0.单例模式-饥汉模式
- springMVC
- 1. springmvc第一天
- 1.1 springMVC概述
- 1.2 springmvc框架搭建及第一个应用程序
- 1.3 @RequestMapping
- 1.4 RequestMapping修饰类
- 1.5 RequestMapping精准化映射
- 1.6 Ant风格URL
- 1.7 带有占位符的url映射
- 1.8 REST风格
- 1.9 RequerstParam获取请求正文
- 2. springmvc第二天
- 2.1 优化
- 2.2 POJO绑定请求参数
- 2.3 RequestHeader获取请求报头信息
- 2.4 CookieValue获取Cookie信息
- 2.5 获取原生ServletAPI
- 2.6 ModelAndView处理模型数据
- 2.7 Map、Model、ModelMap处理模型数据
- 2.8 @SessionAttributes注解
- 2.9 @ModelAttribute无返回值方法及方法入参
- 2.10 @ModelAttribute修饰有返回值类型的方法
- 代码地址
- 3. springmvc补充
- 3-1 springmvc工作原理
- 3-2 springmvc form表单提交中文乱码
- 3-3 数据的格式化
- 3-4 自定义类型转换器
- 3-5 其他知识点
- 3-6 crud代码
- 3-7 @DateTimeFormat日期格式化
- 3-8 数据验证的概念及JSR303验证
- 3-9 Hibernate-Validator验证框架
- 3-10 Controller捕获错误消息
- 3-11 errors标签在页面中获取错误消息
- 3-12 错误消息的定制及国际化
- 3-13 自定义拦截器
- 3-14 Java代码中获取国际化信息
- 3-15 超级链接设置国际化
- 3-16 AJAX支持之@RequestBody
- mybatis
- 1. mybatis第一天
- 1. 为什么使用mybatis
- 2. 下载地址
- 3. hello
- 4. mybatis三种开发模式
- 5. 全局配属属性内容
- 6. DTD设置
- 7. Mapper中的CRUD
- 8. 8.mybatis使用主键自增
- 9. #{}中的参数处理
- 10. #{}与${}区别
- 11. 集合数据的查询
- 12 动态sql
- 12.1 if
- 12.2 choose, when, otherwise
- 12.3 trim, where, set
- 12.4 foreach
- 代码位置
- 2. mybatis第二天
- 1.封装map类型的数据
- 2. resultMap自定义封装规则
- 0代码位置
- 3. mybatis缓存机制
- ssm整合
- 1.maven
- 2.ssm基础环境搭建
- 2-1 引入项目依赖的jar包
- 2-2 引入bootstrap,jquery
- 2-3 创建项目包结构
- 2-4 编写web.xml配置文件
- 2-5 编写sping,springmvc,mybatis配置文件
- 2-6 逆向工程mbg.xml
- shiro安全框架
- 1.shiro简介
- 易购Buy商城
- 第一天
- 1.课程计划
- 2.电商行业背景
- 3.易购Buy介绍
- 4.易购Buy架构
- 5.工程搭建
- 6.工程启动和测试
- 7.ssm框架整合
- 8.整合测试
- 9.svn
- 9.1 svn服务端
- 9.2 svn客户端
- 第二天
- 1.SOA架构分析
- 2.dubbo使用方法
- 3.注册中心
- 4.工程改造
- 5.easyUI
- maven
- 1.maven介绍
- 2.idea配置maven和服务器
- 3.创建web工程
- 4.分模块构建工程
- 5. 代码位置
- 6. nexus
- Luence搜索
- 1.了解搜索技术
- 2.Lucene的基本使用
- solr
- SolrCloud
