微信开发准备(二)--springmvc+mybatis项目结构的搭建
转自:http://www.cuiyongzhi.com/post/34.html
前面一篇有说道如何在MyEclipse中搭建maven项目,这里将继续介绍如何在搭建好的基础maven项目中引入我们常用的javaweb框架——SpringMVC!
①在建立好的maven项目中的pom.xml文件引入依赖,代码如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
< project xmlns = "http://maven.apache.org/POM/4.0.0" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" < modelVersion >4.0.0</ modelVersion > < groupId >wechat.cuiyongzhi.com</ groupId > < artifactId >wechat</ artifactId > < packaging >war</ packaging > < version >0.0.1-SNAPSHOT</ version > < name >wechat</ name > < dependencies > <!-- spring --> < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-test</ artifactId > < version >3.2.0.RELEASE</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-webmvc</ artifactId > < version >3.2.0.RELEASE</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-core</ artifactId > < version >3.2.0.RELEASE</ version > </ dependency > <!-- mybatis --> < dependency > < groupId >org.mybatis</ groupId > < artifactId >mybatis</ artifactId > < version >3.1.1</ version > </ dependency > < dependency > < groupId >org.mybatis</ groupId > < artifactId >mybatis-spring</ artifactId > < version >1.1.1</ version > </ dependency > <!-- mysql --> < dependency > < groupId >mysql</ groupId > < artifactId >mysql-connector-java</ artifactId > < version >5.1.21</ version > </ dependency > <!-- junit测试 --> < dependency > < groupId >junit</ groupId > < artifactId >junit</ artifactId > < version >4.11</ version > < scope >test</ scope > </ dependency > <!-- mysql阿里连接池druid --> < dependency > < groupId >com.alibaba</ groupId > < artifactId >druid</ artifactId > < version >0.2.9</ version > </ dependency > <!-- spring aop包 --> < dependency > < groupId >org.aspectj</ groupId > < artifactId >aspectjweaver</ artifactId > < version >1.7.1</ version > </ dependency > <!-- json包 --> < dependency > < groupId >com.alibaba</ groupId > < artifactId >fastjson</ artifactId > < version >1.2.7</ version > </ dependency > <!-- 文件上传包 --> < dependency > < groupId >commons-fileupload</ groupId > < artifactId >commons-fileupload</ artifactId > < version >1.2.2</ version > </ dependency > <!--servlet包 --> < dependency > < groupId >javax.servlet</ groupId > < artifactId >servlet-api</ artifactId > < version >3.0-alpha-1</ version > </ dependency > < dependency > < groupId >javax.servlet.jsp</ groupId > < artifactId >jsp-api</ artifactId > < version >2.1</ version > < scope >provided</ scope > </ dependency > < dependency > < groupId >javax.servlet</ groupId > < artifactId >jstl</ artifactId > < version >1.2</ version > </ dependency > <!-- 日志包 --> < dependency > < groupId >log4j</ groupId > < artifactId >log4j</ artifactId > < version >1.2.17</ version > </ dependency > </ dependencies > < build > < finalName >wechat</ finalName > </ build > </ project > |
②修改项目路径下的web.xml文件如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
<? xml version = "1.0" encoding = "UTF-8" ?> xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd id = "WebApp_ID" version = "3.0" > < display-name >com.cuiyongzhi.wechat</ display-name > < context-param > < param-name >contextConfigLocation</ param-name > < param-value >classpath:spring.xml,classpath:spring-mybatis.xml</ param-value > <!-- ,classpath:spring-quartz.xml 用于做任务调度 任务定时都可以 --> </ context-param > < context-param > < param-name >log4jConfigLocation</ param-name > < param-value >classpath:log4j.properties</ param-value > </ context-param > < listener > < listener-class >org.springframework.web.util.Log4jConfigListener</ listener-class > </ listener > < context-param > < param-name >spring.profiles.active</ param-name > < param-value >dev</ param-value > </ context-param > < context-param > < param-name >spring.profiles.default</ param-name > < param-value >dev</ param-value > </ context-param > < context-param > < param-name >spring.liveBeansView.mbeanDomain</ param-name > < param-value >dev</ param-value > </ context-param > < filter > < filter-name >encodingFilter</ 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 > < listener > < description >spring监听器</ description > < listener-class >org.springframework.web.context.ContextLoaderListener</ listener-class > </ listener > <!-- 防止内存溢出 --> < listener > < listener-class >org.springframework.web.util.IntrospectorCleanupListener</ listener-class > </ listener > < servlet > < description >spring mvc servlet</ description > < servlet-name >springMvc</ servlet-name > < servlet-class >org.springframework.web.servlet.DispatcherServlet</ servlet-class > < init-param > < description >spring mvc 配置文件</ description > < param-name >contextConfigLocation</ param-name > < param-value >classpath:spring-mvc.xml</ param-value > </ init-param > < load-on-startup >1</ load-on-startup > </ servlet > < servlet > < servlet-name >interface_url-init_servlet</ servlet-name > < servlet-class >com.cuiyongzhi.web.start.InterfaceUrlIntiServlet</ servlet-class > < load-on-startup >1</ load-on-startup > </ servlet > < servlet-mapping > < servlet-name >springMvc</ servlet-name > < url-pattern >/</ url-pattern > </ servlet-mapping > < welcome-file-list > < welcome-file >/index.jsp</ welcome-file > </ welcome-file-list > < session-config > < session-timeout >300</ session-timeout > </ session-config > < error-page > < error-code >404</ error-code > < location >/WEB-INF/error/error.jsp</ location > </ error-page > < error-page > < error-code >500</ error-code > < location >/WEB-INF/error/error.jsp</ location > </ error-page > < servlet-mapping > < servlet-name >default</ servlet-name > < url-pattern >*.css</ url-pattern > </ servlet-mapping > < servlet-mapping > < servlet-name >default</ servlet-name > < url-pattern >*.gif</ url-pattern > </ servlet-mapping > < servlet-mapping > < servlet-name >default</ servlet-name > < url-pattern >*.jpg</ url-pattern > </ servlet-mapping > < servlet-mapping > < servlet-name >default</ servlet-name > < url-pattern >*.js</ url-pattern > </ servlet-mapping > < servlet-mapping > < servlet-name >default</ servlet-name > < url-pattern >*.xhtml</ url-pattern > </ servlet-mapping > < servlet-mapping > < servlet-name >default</ servlet-name > < url-pattern >*.html</ url-pattern > </ servlet-mapping > < filter > < filter-name >DruidWebStatFilter</ filter-name > < filter-class >com.alibaba.druid.support.http.WebStatFilter</ filter-class > < init-param > < param-name >exclusions</ param-name > < param-value >*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*</ param-value > </ init-param > </ filter > < filter-mapping > < filter-name >DruidWebStatFilter</ filter-name > < url-pattern >/*</ url-pattern > </ filter-mapping > < servlet > < servlet-name >DruidStatView</ servlet-name > < servlet-class >com.alibaba.druid.support.http.StatViewServlet</ servlet-class > < init-param > <!-- 允许清空统计数据 --> < param-name >resetEnable</ param-name > < param-value >true</ param-value > </ init-param > < init-param > <!-- 用户名 --> < param-name >loginUsername</ param-name > < param-value >cuiyongzhi</ param-value > </ init-param > < init-param > <!-- 密码 --> < param-name >loginPassword</ param-name > < param-value >123456</ param-value > </ init-param > </ servlet > < servlet-mapping > < servlet-name >DruidStatView</ servlet-name > < url-pattern >/druid/*</ url-pattern > </ servlet-mapping > <!-- 访问监控页面:http://ip:port/projectName/druid/index.html --> < jsp-config > < jsp-property-group > < display-name >jspConfiguration</ display-name > < url-pattern >*.jsp</ url-pattern > < el-ignored >false</ el-ignored > < scripting-invalid >false</ scripting-invalid > < include-prelude >/WEB-INF/common/head.jsp</ include-prelude > </ jsp-property-group > </ jsp-config > </ web-app > |
③添加数据库配置信息,这里项目配置的数据库为mysql,在 resources下新建config.properties配置文件,设置如下:
1
2
3
4
|
validationQuery=SELECT 1 jdbc_url=jdbc:mysql://127.0.0.1:3306/wechat?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull jdbc_username=root jdbc_password=123456789 |
④在 resources下新建spring.xml配置文件,设置如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
|
<? 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=" <!-- 引入属性文件 --> < context:property-placeholder location = "classpath:config.properties" /> <!-- 自动扫描(自动注入) --> < context:component-scan base-package = "com.cuiyongzhi.web.service" /> < context:component-scan base-package = "com.cuiyongzhi.wechat.*" /> </ beans > |
⑤在 resources下新建spring-mvc.xml配置文件,设置如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
<? xml version = "1.0" encoding = "UTF-8" ?> < beans xmlns = "http://www.springframework.org/schema/beans" xmlns:mvc = "http://www.springframework.org/schema/mvc" 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" xsi:schemaLocation="http://www.springframework.org/schema/beans <!-- 自动扫描controller包下的所有类,使其认为spring mvc的控制器 --> < context:component-scan base-package = "com.cuiyongzhi.web.controller" /> <!-- 避免IE执行AJAX时,返回JSON出现下载文件 --> < bean id = "mappingJacksonHttpMessageConverter" class = "org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" > < property name = "supportedMediaTypes" > < list > < value >text/html;charset=UTF-8</ value > </ list > </ property > </ bean > <!-- 启动Spring MVC的注解功能,完成请求和注解POJO的映射 --> < bean class = "org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" > < property name = "messageConverters" > < list > < ref bean = "mappingJacksonHttpMessageConverter" /> <!-- json转换器 --> </ list > </ property > </ bean > <!-- 对模型视图名称的解析,即在模型视图名称添加前后缀 --> < bean class = "org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix = "/WEB-INF/views/" p:suffix = ".jsp" /> < bean id = "multipartResolver" class = "org.springframework.web.multipart.commons.CommonsMultipartResolver" > < property name = "defaultEncoding" > < value >UTF-8</ value > </ property > < property name = "maxUploadSize" > < value >32505856</ value > <!-- 上传文件大小限制为31M,31*1024*1024 --> </ property > < property name = "maxInMemorySize" > < value >4096</ value > </ property > </ bean > </ beans > |
⑥在 resources下新建spring-mybatis.xml配置文件,设置如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
<? 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:tx = "http://www.springframework.org/schema/tx" xmlns:aop = "http://www.springframework.org/schema/aop" xsi:schemaLocation=" "> <!-- 配置数据源 --> < bean name = "dataSource" class = "com.alibaba.druid.pool.DruidDataSource" init-method = "init" destroy-method = "close" > < property name = "url" value = "${jdbc_url}" /> < property name = "username" value = "${jdbc_username}" /> < property name = "password" value = "${jdbc_password}" /> <!-- 初始化连接大小 --> < property name = "initialSize" value = "5" /> <!-- 连接池最大使用连接数量 --> < property name = "maxActive" value = "100" /> <!-- 连接池最大空闲 --> < property name = "maxIdle" value = "10" /> <!-- 连接池最小空闲 --> < property name = "minIdle" value = "0" /> <!-- 获取连接最大等待时间 --> < property name = "maxWait" value = "60000" /> < property name = "poolPreparedStatements" value = "true" /> < property name = "maxPoolPreparedStatementPerConnectionSize" value = "33" /> < property name = "validationQuery" value = "${validationQuery}" /> < property name = "testOnBorrow" value = "false" /> < property name = "testOnReturn" value = "false" /> < property name = "testWhileIdle" value = "true" /> <!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 --> < property name = "timeBetweenEvictionRunsMillis" value = "60000" /> <!-- 配置一个连接在池中最小生存的时间,单位是毫秒 --> < property name = "minEvictableIdleTimeMillis" value = "25200000" /> <!-- 打开removeAbandoned功能 --> < property name = "removeAbandoned" value = "true" /> <!-- 1800秒,也就是30分钟 --> < property name = "removeAbandonedTimeout" value = "1800" /> <!-- 关闭abanded连接时输出错误日志 --> < property name = "logAbandoned" value = "true" /> <!-- 监控数据库 --> <!-- <property name="filters" value="stat" /> --> < property name = "filters" value = "mergeStat" /> </ bean > <!-- myBatis文件 --> < bean id = "sqlSessionFactory" class = "org.mybatis.spring.SqlSessionFactoryBean" > < property name = "dataSource" ref = "dataSource" /> <!-- 自动扫描entity目录, 省掉Configuration.xml里的手工配置 --> < property name = "mapperLocations" value = "classpath:com/cuiyongzhi/web/mapping/*.xml" /> </ bean > < bean class = "org.mybatis.spring.mapper.MapperScannerConfigurer" > < property name = "basePackage" value = "com.cuiyongzhi.web.dao" /> < property name = "sqlSessionFactoryBeanName" value = "sqlSessionFactory" /> </ bean > <!-- 配置事务管理器 --> < bean id = "transactionManager" class = "org.springframework.jdbc.datasource.DataSourceTransactionManager" > < property name = "dataSource" ref = "dataSource" /> </ bean > <!-- 注解方式配置事物 --> <!-- <tx:annotation-driven transaction-manager="transactionManager" /> --> <!-- 拦截器方式配置事物 --> < tx:advice id = "transactionAdvice" transaction-manager = "transactionManager" > < tx:attributes > < tx:method name = "add*" propagation = "REQUIRED" /> < tx:method name = "append*" propagation = "REQUIRED" /> < tx:method name = "insert*" propagation = "REQUIRED" /> < tx:method name = "save*" propagation = "REQUIRED" /> < tx:method name = "update*" propagation = "REQUIRED" /> < tx:method name = "modify*" propagation = "REQUIRED" /> < tx:method name = "edit*" propagation = "REQUIRED" /> < tx:method name = "delete*" propagation = "REQUIRED" /> < tx:method name = "remove*" propagation = "REQUIRED" /> < tx:method name = "repair" propagation = "REQUIRED" /> < tx:method name = "delAndRepair" propagation = "REQUIRED" /> < tx:method name = "get*" propagation = "SUPPORTS" /> < tx:method name = "find*" propagation = "SUPPORTS" /> < tx:method name = "load*" propagation = "SUPPORTS" /> < tx:method name = "search*" propagation = "SUPPORTS" /> < tx:method name = "datagrid*" propagation = "SUPPORTS" /> < tx:method name = "*" propagation = "SUPPORTS" /> </ tx:attributes > </ tx:advice > < aop:config > < aop:pointcut id = "transactionPointcut" expression = "execution(* com.cuiyongzhi.web.service..*Impl.*(..))" /> < aop:advisor pointcut-ref = "transactionPointcut" advice-ref = "transactionAdvice" /> </ aop:config > <!-- 配置druid监控spring jdbc --> < bean id = "druid-stat-interceptor" class = "com.alibaba.druid.support.spring.stat.DruidStatInterceptor" > </ bean > < bean id = "druid-stat-pointcut" class = "org.springframework.aop.support.JdkRegexpMethodPointcut" scope = "prototype" > < property name = "patterns" > < list > < value >com.cuiyongzhi.web.service.*</ value > </ list > </ property > </ bean > < aop:config > < aop:advisor advice-ref = "druid-stat-interceptor" pointcut-ref = "druid-stat-pointcut" /> </ aop:config > </ beans > |
⑦在 resources下新建log4j.properties配置文件,用于日志的输出等级以及输出位置设置,设置如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
log4j.rootLogger=DEBUG,Console,File #ERROR,WARN,INFO,DEBUG log4j.appender.Console=org.apache.log4j.ConsoleAppender log4j.appender.Console.Threshold=DEBUG log4j.appender.Console.Target=System.out log4j.appender.Console.layout=org.apache.log4j.PatternLayout log4j.appender.Console.layout.ConversionPattern=[%p][%d{yyyy-MM-dd HH\:mm\:ss,SSS}][%c]%m%n log4j.appender.File=org.apache.log4j.DailyRollingFileAppender log4j.appender.File.File=${catalina.base}/wechatlogs/wechat.log log4j.appender.File.Threshold=INFO log4j.appender.File.layout=org.apache.log4j.PatternLayout log4j.appender.File.Append=true log4j.appender.File.ImmediateFlush=true log4j.appender.File.DatePattern=yyyy-MM-dd'.log' log4j.appender.File.layout.ConversionPattern=[%p][%d{yyyy-MM-dd HH\:mm\:ss,SSS}][%c]%m%n |
到这里springmvc+mybatis的基本配置文件基本就完成了,大致的项目结构如下:
微信开发准备(二)--springmvc+mybatis项目结构的搭建的更多相关文章
- 从壹开始微服务 [ DDD ] 之二 ║ DDD入门 & 项目结构粗搭建
前言 哈喽大家好,今天是周二,我们的DDD系列文章今天正式开始讲解,我这两天一直在学习,也一直在思考如何才能把这一个系列给合理的传递给大家,并且达到学习的目的,还没有特别好的路线,只是一个大概的模糊的 ...
- Spring+SpringMVC+MyBatis深入学习及搭建(十二)——SpringMVC入门程序(一)
转载请注明出处:http://www.cnblogs.com/Joanna-Yan/p/6999743.html 前面讲到:Spring+SpringMVC+MyBatis深入学习及搭建(十一)——S ...
- Spring+SpringMVC+MyBatis深入学习及搭建(二)——MyBatis原始Dao开发和mapper代理开发
转载请注明出处:http://www.cnblogs.com/Joanna-Yan/p/6869133.html 前面有写到Spring+SpringMVC+MyBatis深入学习及搭建(一)——My ...
- Spring+SpringMVC+MyBatis深入学习及搭建(十六)——SpringMVC注解开发(高级篇)
转载请注明出处:http://www.cnblogs.com/Joanna-Yan/p/7085268.html 前面讲到:Spring+SpringMVC+MyBatis深入学习及搭建(十五)——S ...
- Spring+SpringMVC+MyBatis深入学习及搭建(十二)——SpringMVC入门程序
转载请注明出处:http://www.cnblogs.com/Joanna-Yan/p/6999743.html 前面讲到:Spring+SpringMVC+MyBatis深入学习及搭建(十一)--S ...
- IDEA中maven搭建Spring+SpringMVC+mybatis项目
一.介绍 使用IDEA搭建maven web项目,整合框架Spring+SpringMVC+mybatis 项目结构图:
- Spring+SpringMVC+MyBatis深入学习及搭建(十五)——SpringMVC注解开发(基础篇)
转载请注明出处:http://www.cnblogs.com/Joanna-Yan/p/7065294.html 前面讲到:Spring+SpringMVC+MyBatis深入学习及搭建(十四)--S ...
- 通过IntelliJ IDEA创建maven+springmvc+mybatis项目
第一个springmvc+mybatis项目,通过学习极客学院视频(视频案例通过eclipse搭建,网址为http://www.jikexueyuan.com/course/1430.html),发现 ...
- Spring+SpringMVC+MyBatis深入学习及搭建(十四)——SpringMVC和MyBatis整合
转载请注明出处:http://www.cnblogs.com/Joanna-Yan/p/7010363.html 前面讲到:Spring+SpringMVC+MyBatis深入学习及搭建(十三)--S ...
随机推荐
- windows DPAPI加密解密学习
#include "stdafx.h" #include <windows.h> #include <Wincrypt.h> #include <io ...
- tp5 数据库Db查询操作
$data = Db::query('select * from tf_action'); $data = Db::query('select * from tf_action where id &g ...
- Spring Boot入门——JPA
JPA最大的特点就是可以根据@Entity自动创建你数据库表,用户只需要声明持久层的接口,不需要实现该接口 1.JPA概念 JPA全称Java Persistence API,JPA通过JDK5.0注 ...
- wpf设置字体颜色渐变和字体阴影
<StackPanel Orientation="Horizontal" Grid.Column="1" HorizontalAlignment=&quo ...
- Hive group by实现-就是word 统计
准备数据 SELECT uid, SUM(COUNT) FROM logs GROUP BY uid; hive> SELECT * FROM logs; a 苹果 5 a 橙子 3 a 苹果 ...
- AI探索(二)Tensorflow环境准备
Python + Tensorflow环境安装 Tensorflow支持Windows/Mac/Linux等三种操作系统, 其中windows下python需要安装3.5以上的版本 Mac/Linux ...
- nyoj-1278-Prototypes analyze(二叉排序树模板)
题目链接 思路:建树之后,判断有多少种不同的树. 判断不同的树,简单的思路是遍历数组,判断数组后面是否存在一样的树 /* Name:NYOJ-1278-Prototypes analyze Copyr ...
- pcre函数详解
PCRE是一个NFA正则引擎,不然不能提供完全与Perl一致的正则语法功能.但它同时也实现了DFA,只是满足数学意义上的正则. PCRE提供了19个接口函数,为了简单介绍,使用PCRE内带的测试程序( ...
- memcache应对缓存失效问题
.两个key,一个key用来存放数据,另一个用来标记失效时间 比如key是aaa,设置失效时间为30s,则另一个key为expire_aaa,失效时间为25s. 在取数据时,用multiget,同时取 ...
- pip镜像源
pip是用国内镜像源 https://pypi.python.org/http://pypi.douban.com/simple/ http://mirrors.aliyun.com/pypi/sim ...