jar说明
[ aop核心]
com. springsource. net. sf. cglib- 2.2 .0 . jar
com. springsource. org. aopalliance- 1.0 .0 . jar
com. springsource. org. aspectj. weaver- 1.6 .8 . RELEASE. jar
[ ioc核心]
commons- logging- 1.1 .3 . jar
spring- aop- 4.0 .0 . RELEASE. jar
spring- aspects- 4.0 .0 . RELEASE. jar
spring- beans- 4.0 .0 . RELEASE. jar
spring- context- 4.0 .0 . RELEASE. jar
spring- core- 4.0 .0 . RELEASE. jar
spring- expression- 4.0 .0 . RELEASE. jar
[ jdbc核心]
spring- jdbc- 4.0 .0 . RELEASE. jar
spring- orm- 4.0 .0 . RELEASE. jar
spring- tx- 4.0 .0 . RELEASE. jar
【数据源、驱动】
mysql- connector- java- 5.1 .37 - bin. jar
c3p0- 0.9 .1 .2 . jar
[ 测试模块]
spring- test- 4.0 .0 . RELEASE. jar
[ springmvc 核心]
spring- web- 4.0 .0 . RELEASE. jar
spring- webmvc- 4.0 .0 . RELEASE. jar
[ 文件上传下载]
commons- fileupload- 1.2 .1 . jar
commons- io- 2.0 . jar
[ jsp 标签]
jstl. jar
standard. jar
[ 数据校验]
hibernate- validator- 5.0 .0 . CR2. jar
hibernate- validator- annotation- processor- 5.0 .0 . CR2. jar4
classmate- 0.8 .0 . jar
jboss- logging- 3.1 .1 . GA. jar
validation- api- 1.1 .0 . CR1. jar
[ ajax ]
jackson- annotations- 2.1 .5 . jar
jackson- core- 2.1 .5 . jar
jackson- databind- 2.1 .5 . jar
[ 验证码]
kaptcha- 2.3 .2 . jar
[ mybatis + 缓存]
ehcache- core- 2.6 .8 . jar
mybatis- ehcache- 1.0 .3 . jar
log4j- 1.2 .17 . jar
slf4j- api- 1.7 .21 . jar
slf4j- log4j12- 1.7 .21 . jar
web. xml文件配置
< ? xml version= "1.0" encoding= "UTF-8" ? >
< 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_4_0.xsd"
version= "4.0" >
< display- name> SSM< / display- name>
< welcome- file- list>
< welcome- file> index. jsp< / welcome- file>
< / welcome- file- list>
< ! -- 配置Spring容器启动:-- >
< ! -- needed for ContextLoaderListener-- >
< context- param>
< param- name> contextConfigLocation< / param- name>
< ! -- 指定spring配置文件位置 -- >
< param- value> classpath: spring/ applicationContext. xml< / param- value>
< / context- param>
< ! -- Bootstraps the root web application context before servlet initialization -- >
< listener>
< listener- class > org. springframework. web. context. ContextLoaderListener< / listener- class >
< / listener>
< ! -- 配置springmvc的前端控制器 -- >
< ! -- The front controller of this Spring Web application, responsible for handling all application requests -- >
< servlet>
< servlet- name> springDispatcherServlet< / servlet- name>
< servlet- class > org. springframework. web. servlet. DispatcherServlet< / servlet- class >
< init- param>
< param- name> contextConfigLocation< / param- name>
< param- value> classpath: spring/ applicationContext- mvc. xml< / param- value>
< / init- param>
< load- on- startup> 1 < / load- on- startup>
< / servlet>
< ! -- Map all requests to the DispatcherServlet for handling -- >
< servlet- mapping>
< servlet- name> springDispatcherServlet< / servlet- name>
< url- pattern> / < / url- pattern>
< / servlet- mapping>
< ! -- 两个标准配置 -- >
< ! -- 字符编码 -- >
< filter>
< filter- name> CharacterEncodingFilter< / filter- name>
< filter- class > org. springframework. web. filter. CharacterEncodingFilter< / filter- class >
< init- param>
< param- name> encoding< / param- name>
< param- value> utf- 8 < / param- value>
< / init- param>
< init- param>
< param- name> forceEncoding< / param- name>
< param- value> true < / param- value>
< / init- param>
< / filter>
< filter- mapping>
< filter- name> CharacterEncodingFilter< / filter- name>
< url- pattern>
applicationContext. 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"
xmlns: aop= "http://www.springframework.org/schema/aop"
xmlns: mybatis- spring= "http://mybatis.org/schema/mybatis-spring"
xsi: schemaLocation= "http: / / mybatis. org/ schema/ mybatis- spring http: / / mybatis. org/ schema/ mybatis- spring- 1.2 . xsd
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- 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">
< ! -- Spring除过控制器不要,剩下的业务逻辑组件都要,包括dao,包括service -- >
< context: component- scan base- package = "com.liang" >
< ! -- 扫描排除不写use- default - filters= "false" -- >
< context: exclude- filter type= "annotation" expression= "org.springframework.stereotype.Controller" / >
< / context: component- scan>
< ! -- 0 、导入外部配置文件 -- >
< context: property- placeholder location= "classpath:dbconfig.properties" / >
< ! -- 1 、配数据源 -- >
< bean id= "ds" class = "com.mchange.v2.c3p0.ComboPooledDataSource" >
< property name= "user" value= "${jdbc.user}" > < / property>
< property name= "password" value= "${jdbc.password}" > < / property>
< property name= "driverClass" value= "${jdbc.driverClass}" > < / property>
< property name= "jdbcUrl" value= "${jdbc.jdbcUrl}" > < / property>
< property name= "maxPoolSize" value= "${jdbc.maxPoolSize}" > < / property>
< property name= "minPoolSize" value= "${jdbc.minPoolSize}" > < / property>
< / bean>
< ! -- 2 、配置JdbcTemplate操作数据库。pass -- >
< ! -- 3 、配置使用mybatis操作数据库 -- >
< ! -- 可以根据配置文件得到sqlSessionFactory -- >
< bean id= "sqlSessionFactoryBean" class = "org.mybatis.spring.SqlSessionFactoryBean" >
< ! -- 指定配置文件位置 -- >
< property name= "configLocation" value= "classpath:mybatis/mybatis-config.xml" > < / property>
< property name= "dataSource" ref= "ds" > < / property>
< ! -- 指定xml映射文件的位置 -- >
< property name= "mapperLocations" value= "classpath:mybatis/mapper/*.xml" > < / property>
< / bean>
< ! -- 我们要把每一个dao接口的实现加入到ioc容器; -- >
< bean class = "org.mybatis.spring.mapper.MapperScannerConfigurer" >
< ! -- 指定dao接口所在的包 -- >
< property name= "basePackage" value= "com.liang.dao" > < / property>
< / bean>
< ! -- < mybatis- spring: scan base- package = "com.liang.dao" / > -- >
< ! -- 4 、配置事务控制; 配置事务管理器,让他控制住数据源里面的链接的关闭和提交 -- >
< bean id= "tm" class = "org.springframework.jdbc.datasource.DataSourceTransactionManager" >
< property name= "dataSource" ref= "ds" > < / property>
< / bean>
< ! -- 5 、基于xml配置,配置事务;哪些方法切入事务还要写切入点表达式 -- >
< aop: config>
< ! -- 配置切入点表达式 -- >
< aop: pointcut expression= "execution(* com.liang.service.*.*(..))" id= "txPoint" / >
< aop: advisor advice- ref= "myTx" pointcut- ref= "txPoint" / >
< / aop: config>
< ! -- 6 、配置事务增强、事务属性、事务建议
transaction- manager= "tm" :指定要配置的事务管理器的id
-- >
< tx: advice id= "myTx" transaction- manager= "tm" >
< ! -- 配置事务属性 -- >
< tx: attributes>
< tx: method name= "*" rollback- for = "java.lang.Exception" / >
< tx: method name= "get*" read- only= "true" / >
< ! -- < tx: method name= "insertEmp" isolation= "READ_UNCOMMITTED" / > -- >
< / tx: attributes>
< / tx: advice>
< / beans>
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= "lazyLoadingEnabled" value= "true" / >
< setting name= "aggressiveLazyLoading" value= "false" / >
< setting name= "cacheEnabled" value= "true" / >
< / settings>
< plugins>
< plugin interceptor= "com.github.pagehelper.PageInterceptor" > < / plugin>
< / plugins>
< / configuration>
dbconfig. properties 文件配置
jdbc. user= root
jdbc. password= root
jdbc. jdbcUrl= jdbc: mysql: / / localhost: 3306 / mybatis
jdbc. driverClass= com. mysql. jdbc. Driver
jdbc. maxPoolSize= 20
jdbc. minPoolSize= 5
applicationContext- mvc. 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/ mvc http: / / www. springframework. org/ schema/ mvc/ spring- mvc- 4.0 . xsd
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- 4.0 . xsd">
< ! -- SpringMVC只扫描控制器;禁用默认的规则 -- >
< context: component- scan base- package = "com.liang" 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/pages/" > < / property>
< property name= "suffix" value= ".jsp" > < / property>
< / bean>
< ! -- 配置文件上传解析器 -- >
< bean id= "multipartResolver" class = "org.springframework.web.multipart.commons.CommonsMultipartResolver" >
< property name= "defaultEncoding" value= "utf-8" > < / property>
< property name= "maxUploadSize" value= "#{1024*1024*20}" > < / property>
< / bean>
< ! -- 扫静态资源 -- >
< mvc: default - servlet- handler/ >
< ! -- 扫动态 -- >
< mvc: annotation- driven> < / mvc: annotation- driven>
< / beans>
log4j. xml 文件配置
< ? xml version= "1.0" encoding= "UTF-8" ? >
< ! DOCTYPE log4j: configuration SYSTEM "log4j.dtd" >
< log4j: configuration xmlns: log4j= "http://jakarta.apache.org/log4j/" >
< appender name= "STDOUT" class = "org.apache.log4j.ConsoleAppender" >
< param name= "Encoding" value= "UTF-8" / >
< layout class = "org.apache.log4j.PatternLayout" >
< param name= "ConversionPattern" value= "%-5p %d{MM-dd HH:mm:ss,SSS} %m (%F:%L) \n" / >
< / layout>
< / appender>
< logger name= "java.sql" >
< level value= "debug" / >
< / logger>
< logger name= "org.apache.ibatis" >
< level value= "info" / >
< / logger>
< root>
< level value= "debug" / >
< appender- ref ref= "STDOUT" / >
< / root>
< / log4j: configuration>
ehcache. xml
< ? xml version= "1.0" encoding= "UTF-8" ? >
< ehcache xmlns: xsi= "http://www.w3.org/2001/XMLSchema-instance"
xsi: noNamespaceSchemaLocation= "../config/ehcache.xsd" >
< ! -- 磁盘保存路径 -- >
< diskStore path= "D:\44\ehcache" / >
< defaultCache
maxElementsInMemory= "1"
maxElementsOnDisk= "10000000"
eternal= "false"
overflowToDisk= "true"
timeToIdleSeconds= "120"
timeToLiveSeconds= "120"
diskExpiryThreadIntervalSeconds= "120"
memoryStoreEvictionPolicy= "LRU" >
< / defaultCache>
< / ehcache>
< ! --
属性说明:
l diskStore:指定数据在磁盘中的存储位置。
l defaultCache:当借助CacheManager. add ( "demoCache" ) 创建Cache时,EhCache便会采用< defalutCache/ > 指定的的管理策略
以下属性是必须的:
l maxElementsInMemory - 在内存中缓存的element的最大数目
l maxElementsOnDisk - 在磁盘上缓存的element的最大数目,若是0 表示无穷大
l eternal - 设定缓存的elements是否永远不过期。如果为true ,则缓存的数据始终有效,如果为false 那么还要根据timeToIdleSeconds,timeToLiveSeconds判断
l overflowToDisk - 设定当内存缓存溢出的时候是否将过期的element缓存到磁盘上
以下属性是可选的:
l timeToIdleSeconds - 当缓存在EhCache中的数据前后两次访问的时间超过timeToIdleSeconds的属性取值时,这些数据便会删除,默认值是0 , 也就是可闲置时间无穷大
l timeToLiveSeconds - 缓存element的有效生命期,默认是0. , 也就是element存活时间无穷大
diskSpoolBufferSizeMB 这个参数设置DiskStore ( 磁盘缓存) 的缓存区大小. 默认是30 MB. 每个Cache都应该有自己的一个缓冲区.
l diskPersistent - 在VM重启的时候是否启用磁盘保存EhCache中的数据,默认是false 。
l diskExpiryThreadIntervalSeconds - 磁盘缓存的清理线程运行间隔,默认是120 秒。每个120 s,相应的线程会进行一次EhCache中数据的清理工作
l memoryStoreEvictionPolicy - 当内存缓存达到最大,有新的element加入的时候, 移除缓存中element的策略。默认是LRU(最近最少使用),可选的有LFU(最不常使用)和FIFO(先进先出)
-- >