diff --git a/docs/.vuepress/themeConfig/index.js b/docs/.vuepress/themeConfig/index.js index b425f95c..df506ead 100644 --- a/docs/.vuepress/themeConfig/index.js +++ b/docs/.vuepress/themeConfig/index.js @@ -15,7 +15,7 @@ module.exports = { sidebar, lastUpdated: "Last Updated", sidebarDepth: 2, - repo: "", + repo: "https://github.com/staven630/blog", editLinks: false, footer: { createYear: 2021, diff --git "a/md/Java\346\241\206\346\236\266/Spring/10_Spring\345\237\272\344\272\216Annotation\350\243\205\351\205\215Bean.md" "b/md/Java\346\241\206\346\236\266/Spring/10_Spring\345\237\272\344\272\216Annotation\350\243\205\351\205\215Bean.md" deleted file mode 100644 index 65ca8bd8..00000000 --- "a/md/Java\346\241\206\346\236\266/Spring/10_Spring\345\237\272\344\272\216Annotation\350\243\205\351\205\215Bean.md" +++ /dev/null @@ -1 +0,0 @@ -Annotation diff --git "a/md/Java\346\241\206\346\236\266/Spring/12_Spring JDK\345\212\250\346\200\201\344\273\243\347\220\206.md" "b/md/Java\346\241\206\346\236\266/Spring/12_Spring JDK\345\212\250\346\200\201\344\273\243\347\220\206.md" deleted file mode 100644 index 337d293d..00000000 --- "a/md/Java\346\241\206\346\236\266/Spring/12_Spring JDK\345\212\250\346\200\201\344\273\243\347\220\206.md" +++ /dev/null @@ -1 +0,0 @@ -Proxy diff --git "a/md/Java\346\241\206\346\236\266/Spring/13_Spring\350\207\252\345\212\250\350\243\205\351\205\215Bean.md" "b/md/Java\346\241\206\346\236\266/Spring/13_Spring\350\207\252\345\212\250\350\243\205\351\205\215Bean.md" deleted file mode 100644 index fd9885b9..00000000 --- "a/md/Java\346\241\206\346\236\266/Spring/13_Spring\350\207\252\345\212\250\350\243\205\351\205\215Bean.md" +++ /dev/null @@ -1 +0,0 @@ -Auto diff --git "a/md/Java\346\241\206\346\236\266/Spring/11_Spring Aop\346\246\202\350\277\260.md" "b/md/Java\346\241\206\346\236\266/Spring/1_Spring IOC\345\256\271\345\231\250/10_\345\256\271\345\231\250\344\270\216Bean\346\211\251\345\261\225.md" similarity index 100% rename from "md/Java\346\241\206\346\236\266/Spring/11_Spring Aop\346\246\202\350\277\260.md" rename to "md/Java\346\241\206\346\236\266/Spring/1_Spring IOC\345\256\271\345\231\250/10_\345\256\271\345\231\250\344\270\216Bean\346\211\251\345\261\225.md" diff --git "a/md/Java\346\241\206\346\236\266/Spring/1_Spring IoC\345\256\271\345\231\250.md" "b/md/Java\346\241\206\346\236\266/Spring/1_Spring IOC\345\256\271\345\231\250/1_Spring IoC\345\256\271\345\231\250.md" similarity index 100% rename from "md/Java\346\241\206\346\236\266/Spring/1_Spring IoC\345\256\271\345\231\250.md" rename to "md/Java\346\241\206\346\236\266/Spring/1_Spring IOC\345\256\271\345\231\250/1_Spring IoC\345\256\271\345\231\250.md" diff --git "a/md/Java\346\241\206\346\236\266/Spring/2_Spring\345\256\271\345\231\250\345\210\235\345\247\213\345\214\226.md" "b/md/Java\346\241\206\346\236\266/Spring/1_Spring IOC\345\256\271\345\231\250/2_Spring\345\256\271\345\231\250\345\210\235\345\247\213\345\214\226.md" similarity index 100% rename from "md/Java\346\241\206\346\236\266/Spring/2_Spring\345\256\271\345\231\250\345\210\235\345\247\213\345\214\226.md" rename to "md/Java\346\241\206\346\236\266/Spring/1_Spring IOC\345\256\271\345\231\250/2_Spring\345\256\271\345\231\250\345\210\235\345\247\213\345\214\226.md" diff --git "a/md/Java\346\241\206\346\236\266/Spring/4_Spring Bean\347\232\204\345\256\232\344\271\211\345\217\212\351\205\215\347\275\256\345\261\236\346\200\247.md" "b/md/Java\346\241\206\346\236\266/Spring/1_Spring IOC\345\256\271\345\231\250/3_Spring Bean\347\232\204\345\256\232\344\271\211\345\217\212\351\205\215\347\275\256\345\261\236\346\200\247.md" similarity index 100% rename from "md/Java\346\241\206\346\236\266/Spring/4_Spring Bean\347\232\204\345\256\232\344\271\211\345\217\212\351\205\215\347\275\256\345\261\236\346\200\247.md" rename to "md/Java\346\241\206\346\236\266/Spring/1_Spring IOC\345\256\271\345\231\250/3_Spring Bean\347\232\204\345\256\232\344\271\211\345\217\212\351\205\215\347\275\256\345\261\236\346\200\247.md" diff --git "a/md/Java\346\241\206\346\236\266/Spring/5_Spring Bean\345\256\236\344\276\213\345\214\226.md" "b/md/Java\346\241\206\346\236\266/Spring/1_Spring IOC\345\256\271\345\231\250/4_Spring Bean\345\256\236\344\276\213\345\214\226.md" similarity index 100% rename from "md/Java\346\241\206\346\236\266/Spring/5_Spring Bean\345\256\236\344\276\213\345\214\226.md" rename to "md/Java\346\241\206\346\236\266/Spring/1_Spring IOC\345\256\271\345\231\250/4_Spring Bean\345\256\236\344\276\213\345\214\226.md" diff --git "a/md/Java\346\241\206\346\236\266/Spring/6_Spring Bean\347\232\204\344\275\234\347\224\250\345\237\237.md" "b/md/Java\346\241\206\346\236\266/Spring/1_Spring IOC\345\256\271\345\231\250/5_Spring Bean\347\232\204\344\275\234\347\224\250\345\237\237.md" similarity index 100% rename from "md/Java\346\241\206\346\236\266/Spring/6_Spring Bean\347\232\204\344\275\234\347\224\250\345\237\237.md" rename to "md/Java\346\241\206\346\236\266/Spring/1_Spring IOC\345\256\271\345\231\250/5_Spring Bean\347\232\204\344\275\234\347\224\250\345\237\237.md" diff --git "a/md/Java\346\241\206\346\236\266/Spring/3_Spring\344\276\235\350\265\226\346\263\250\345\205\245\344\270\216\345\256\236\347\216\260\346\226\271\345\274\217.md" "b/md/Java\346\241\206\346\236\266/Spring/1_Spring IOC\345\256\271\345\231\250/6_Spring\344\276\235\350\265\226\346\263\250\345\205\245\344\270\216\345\256\236\347\216\260\346\226\271\345\274\217.md" similarity index 97% rename from "md/Java\346\241\206\346\236\266/Spring/3_Spring\344\276\235\350\265\226\346\263\250\345\205\245\344\270\216\345\256\236\347\216\260\346\226\271\345\274\217.md" rename to "md/Java\346\241\206\346\236\266/Spring/1_Spring IOC\345\256\271\345\231\250/6_Spring\344\276\235\350\265\226\346\263\250\345\205\245\344\270\216\345\256\236\347\216\260\346\226\271\345\274\217.md" index 6d125ce2..757f900b 100644 --- "a/md/Java\346\241\206\346\236\266/Spring/3_Spring\344\276\235\350\265\226\346\263\250\345\205\245\344\270\216\345\256\236\347\216\260\346\226\271\345\274\217.md" +++ "b/md/Java\346\241\206\346\236\266/Spring/1_Spring IOC\345\256\271\345\231\250/6_Spring\344\276\235\350\265\226\346\263\250\345\205\245\344\270\216\345\256\236\347\216\260\346\226\271\345\274\217.md" @@ -1,6 +1,8 @@ +## 依赖注入方式 +   Spring 中有两种常见的依赖注入方式:属性注入和构造器注入。 -## 构造函数注入 +### 构造函数注入   在 Bean 的配置中,使用 constructor-arg 的子元素配置依赖的对象,对应的 Bean 类需具备对应参数的构造函数。容器反射调用带参数的构造函数进行依赖对象的初始化。 @@ -52,7 +54,7 @@ public class UserService {   constructor-arg 配置子元素对应到构造函数的参数,在 ref 子元素的 bean 属性中设置依赖 bean 的 id。 -## 设置值注入 +### 设置值注入   设置值注入使用的是属性的 setter 方法来注入依赖对象。 @@ -92,6 +94,6 @@ public class UserService {   property 子元素注入依赖对象,name 对应 bean 类中的属性名,ref 设置为依赖 bean 的 id。 -## 总结 +### 总结   Spring 官方推荐使用构造器注入方式。实际项目中,推荐使用构造器注入方式注入强制依赖项,使用设置值方式注入可选依赖项。 diff --git "a/md/Java\346\241\206\346\236\266/Spring/14_Spring CGLib\345\212\250\346\200\201\344\273\243\347\220\206.md" "b/md/Java\346\241\206\346\236\266/Spring/1_Spring IOC\345\256\271\345\231\250/7_Spring\344\276\235\350\265\226\346\263\250\345\205\245\347\232\204\351\205\215\347\275\256.md" similarity index 100% rename from "md/Java\346\241\206\346\236\266/Spring/14_Spring CGLib\345\212\250\346\200\201\344\273\243\347\220\206.md" rename to "md/Java\346\241\206\346\236\266/Spring/1_Spring IOC\345\256\271\345\231\250/7_Spring\344\276\235\350\265\226\346\263\250\345\205\245\347\232\204\351\205\215\347\275\256.md" diff --git "a/md/Java\346\241\206\346\236\266/Spring/7_Spring\344\270\255\347\232\204bean\347\224\237\345\221\275\345\221\250\346\234\237.md" "b/md/Java\346\241\206\346\236\266/Spring/1_Spring IOC\345\256\271\345\231\250/8_Spring\344\270\255\347\232\204bean\347\224\237\345\221\275\345\221\250\346\234\237.md" similarity index 100% rename from "md/Java\346\241\206\346\236\266/Spring/7_Spring\344\270\255\347\232\204bean\347\224\237\345\221\275\345\221\250\346\234\237.md" rename to "md/Java\346\241\206\346\236\266/Spring/1_Spring IOC\345\256\271\345\231\250/8_Spring\344\270\255\347\232\204bean\347\224\237\345\221\275\345\221\250\346\234\237.md" diff --git "a/md/Java\346\241\206\346\236\266/Spring/15_Spring\351\200\232\347\237\245\347\261\273\345\236\213\345\222\214\345\210\233\345\273\272AOP\344\273\243\347\220\206.md" "b/md/Java\346\241\206\346\236\266/Spring/1_Spring IOC\345\256\271\345\231\250/9_Spring\345\237\272\344\272\216XML\350\243\205\351\205\215Bean.md" similarity index 100% rename from "md/Java\346\241\206\346\236\266/Spring/15_Spring\351\200\232\347\237\245\347\261\273\345\236\213\345\222\214\345\210\233\345\273\272AOP\344\273\243\347\220\206.md" rename to "md/Java\346\241\206\346\236\266/Spring/1_Spring IOC\345\256\271\345\231\250/9_Spring\345\237\272\344\272\216XML\350\243\205\351\205\215Bean.md" diff --git "a/md/Java\346\241\206\346\236\266/Spring/16_Spring\344\275\277\347\224\250AspectJ\345\274\200\345\217\221AOP.md" "b/md/Java\346\241\206\346\236\266/Spring/2_Spring\346\263\250\350\247\243/1_Java\346\263\250\350\247\243.md" similarity index 100% rename from "md/Java\346\241\206\346\236\266/Spring/16_Spring\344\275\277\347\224\250AspectJ\345\274\200\345\217\221AOP.md" rename to "md/Java\346\241\206\346\236\266/Spring/2_Spring\346\263\250\350\247\243/1_Java\346\263\250\350\247\243.md" diff --git "a/md/Java\346\241\206\346\236\266/Spring/17_Spring JDBCTemplate.md" "b/md/Java\346\241\206\346\236\266/Spring/2_Spring\346\263\250\350\247\243/2_Spring\346\224\257\346\214\201\347\232\204\346\263\250\350\247\243.md" similarity index 100% rename from "md/Java\346\241\206\346\236\266/Spring/17_Spring JDBCTemplate.md" rename to "md/Java\346\241\206\346\236\266/Spring/2_Spring\346\263\250\350\247\243/2_Spring\346\224\257\346\214\201\347\232\204\346\263\250\350\247\243.md" diff --git "a/md/Java\346\241\206\346\236\266/Spring/18_Spring\344\272\213\345\212\241\347\256\241\347\220\206.md" "b/md/Java\346\241\206\346\236\266/Spring/2_Spring\346\263\250\350\247\243/3_Spring\346\224\257\346\214\201\347\232\204Java\346\240\207\345\207\206\346\263\250\350\247\243.md" similarity index 100% rename from "md/Java\346\241\206\346\236\266/Spring/18_Spring\344\272\213\345\212\241\347\256\241\347\220\206.md" rename to "md/Java\346\241\206\346\236\266/Spring/2_Spring\346\263\250\350\247\243/3_Spring\346\224\257\346\214\201\347\232\204Java\346\240\207\345\207\206\346\263\250\350\247\243.md" diff --git "a/md/Java\346\241\206\346\236\266/Spring/19_Spring\345\237\272\344\272\216XML\345\256\236\347\216\260\344\272\213\345\212\241\347\256\241\347\220\206.md" "b/md/Java\346\241\206\346\236\266/Spring/2_Spring\346\263\250\350\247\243/4_Spring\345\256\271\345\231\250\351\205\215\347\275\256\346\263\250\350\247\243.md" similarity index 100% rename from "md/Java\346\241\206\346\236\266/Spring/19_Spring\345\237\272\344\272\216XML\345\256\236\347\216\260\344\272\213\345\212\241\347\256\241\347\220\206.md" rename to "md/Java\346\241\206\346\236\266/Spring/2_Spring\346\263\250\350\247\243/4_Spring\345\256\271\345\231\250\351\205\215\347\275\256\346\263\250\350\247\243.md" diff --git "a/md/Java\346\241\206\346\236\266/Spring/20_Spring\346\265\213\350\257\225.md" "b/md/Java\346\241\206\346\236\266/Spring/2_Spring\346\263\250\350\247\243/5_\350\207\252\345\212\250\350\243\205\351\205\215.md" similarity index 100% rename from "md/Java\346\241\206\346\236\266/Spring/20_Spring\346\265\213\350\257\225.md" rename to "md/Java\346\241\206\346\236\266/Spring/2_Spring\346\263\250\350\247\243/5_\350\207\252\345\212\250\350\243\205\351\205\215.md" diff --git "a/md/Java\346\241\206\346\236\266/Spring/8_Spring\345\237\272\344\272\216XML\350\243\205\351\205\215Bean.md" "b/md/Java\346\241\206\346\236\266/Spring/2_Spring\346\263\250\350\247\243/6_\345\237\272\344\272\216Java\344\273\243\347\240\201\347\232\204\351\205\215\347\275\256.md" similarity index 100% rename from "md/Java\346\241\206\346\236\266/Spring/8_Spring\345\237\272\344\272\216XML\350\243\205\351\205\215Bean.md" rename to "md/Java\346\241\206\346\236\266/Spring/2_Spring\346\263\250\350\247\243/6_\345\237\272\344\272\216Java\344\273\243\347\240\201\347\232\204\351\205\215\347\275\256.md" diff --git "a/md/Java\346\241\206\346\236\266/Spring/9_Spring\345\237\272\344\272\216Annotation\345\256\236\347\216\260\344\272\213\345\212\241\347\256\241\347\220\206.md" "b/md/Java\346\241\206\346\236\266/Spring/3_Spring \346\225\260\346\215\256\350\256\277\351\227\256/1_Spring JDBC\346\250\241\346\235\277\347\261\273.md" similarity index 100% rename from "md/Java\346\241\206\346\236\266/Spring/9_Spring\345\237\272\344\272\216Annotation\345\256\236\347\216\260\344\272\213\345\212\241\347\256\241\347\220\206.md" rename to "md/Java\346\241\206\346\236\266/Spring/3_Spring \346\225\260\346\215\256\350\256\277\351\227\256/1_Spring JDBC\346\250\241\346\235\277\347\261\273.md" diff --git "a/md/\345\211\215\347\253\257\345\217\257\350\247\206\345\214\226/Cesium.js/Cesium.js\350\210\252\345\220\221\350\247\222/\345\201\217\350\210\252\350\247\222.md" "b/md/Java\346\241\206\346\236\266/Spring/3_Spring \346\225\260\346\215\256\350\256\277\351\227\256/2_Spring DAO.md" similarity index 100% rename from "md/\345\211\215\347\253\257\345\217\257\350\247\206\345\214\226/Cesium.js/Cesium.js\350\210\252\345\220\221\350\247\222/\345\201\217\350\210\252\350\247\222.md" rename to "md/Java\346\241\206\346\236\266/Spring/3_Spring \346\225\260\346\215\256\350\256\277\351\227\256/2_Spring DAO.md" diff --git "a/md/Java\346\241\206\346\236\266/Spring/3_Spring \346\225\260\346\215\256\350\256\277\351\227\256/3_Spring\346\225\264\345\220\210JPA.md" "b/md/Java\346\241\206\346\236\266/Spring/3_Spring \346\225\260\346\215\256\350\256\277\351\227\256/3_Spring\346\225\264\345\220\210JPA.md" new file mode 100644 index 00000000..e69de29b diff --git "a/md/Java\346\241\206\346\236\266/Spring/4_Spring\344\272\213\345\212\241\347\256\241\347\220\206/1_Java\344\272\213\345\212\241\347\256\241\347\220\206.md" "b/md/Java\346\241\206\346\236\266/Spring/4_Spring\344\272\213\345\212\241\347\256\241\347\220\206/1_Java\344\272\213\345\212\241\347\256\241\347\220\206.md" new file mode 100644 index 00000000..e69de29b diff --git "a/md/Java\346\241\206\346\236\266/Spring/4_Spring\344\272\213\345\212\241\347\256\241\347\220\206/2_Spring\344\272\213\345\212\241\347\256\241\347\220\206.md" "b/md/Java\346\241\206\346\236\266/Spring/4_Spring\344\272\213\345\212\241\347\256\241\347\220\206/2_Spring\344\272\213\345\212\241\347\256\241\347\220\206.md" new file mode 100644 index 00000000..e69de29b diff --git "a/md/Java\346\241\206\346\236\266/Spring/4_Spring\344\272\213\345\212\241\347\256\241\347\220\206/3_\345\237\272\344\272\216\346\225\260\346\215\256\346\272\220\344\272\213\345\212\241\347\256\241\347\220\206\345\231\250\347\232\204\344\272\213\345\212\241.md" "b/md/Java\346\241\206\346\236\266/Spring/4_Spring\344\272\213\345\212\241\347\256\241\347\220\206/3_\345\237\272\344\272\216\346\225\260\346\215\256\346\272\220\344\272\213\345\212\241\347\256\241\347\220\206\345\231\250\347\232\204\344\272\213\345\212\241.md" new file mode 100644 index 00000000..e69de29b diff --git "a/md/Java\346\241\206\346\236\266/Spring/5_Spring AOP/1_AOP\346\246\202\350\277\260\345\217\212\344\273\243\347\220\206.md" "b/md/Java\346\241\206\346\236\266/Spring/5_Spring AOP/1_AOP\346\246\202\350\277\260\345\217\212\344\273\243\347\220\206.md" new file mode 100644 index 00000000..e69de29b diff --git "a/md/Java\346\241\206\346\236\266/Spring/5_Spring AOP/2_Spring AOP\346\241\206\346\236\266-AspectJ.md" "b/md/Java\346\241\206\346\236\266/Spring/5_Spring AOP/2_Spring AOP\346\241\206\346\236\266-AspectJ.md" new file mode 100644 index 00000000..e69de29b diff --git "a/md/Java\346\241\206\346\236\266/Spring/5_Spring AOP/3_Spring AOP\345\256\236\347\216\260\344\270\216\351\205\215\347\275\256.md" "b/md/Java\346\241\206\346\236\266/Spring/5_Spring AOP/3_Spring AOP\345\256\236\347\216\260\344\270\216\351\205\215\347\275\256.md" new file mode 100644 index 00000000..e69de29b diff --git "a/md/Java\346\241\206\346\236\266/Spring/5_Spring AOP/Spring\346\225\264\345\220\210JPA.md" "b/md/Java\346\241\206\346\236\266/Spring/5_Spring AOP/Spring\346\225\264\345\220\210JPA.md" new file mode 100644 index 00000000..e69de29b diff --git "a/md/Java\346\241\206\346\236\266/Spring/6_Spring\346\265\213\350\257\225/Spring\346\265\213\350\257\225.md" "b/md/Java\346\241\206\346\236\266/Spring/6_Spring\346\265\213\350\257\225/Spring\346\265\213\350\257\225.md" new file mode 100644 index 00000000..e69de29b diff --git "a/md/\345\211\215\347\253\257\345\217\257\350\247\206\345\214\226/Cesium.js/Cesium.js-\347\233\270\346\234\272\346\216\247\345\210\266md" "b/md/\345\211\215\347\253\257\345\217\257\350\247\206\345\214\226/Cesium.js/Cesium.js-\347\233\270\346\234\272\346\216\247\345\210\266.md" similarity index 100% rename from "md/\345\211\215\347\253\257\345\217\257\350\247\206\345\214\226/Cesium.js/Cesium.js-\347\233\270\346\234\272\346\216\247\345\210\266md" rename to "md/\345\211\215\347\253\257\345\217\257\350\247\206\345\214\226/Cesium.js/Cesium.js-\347\233\270\346\234\272\346\216\247\345\210\266.md" diff --git a/scripts/rename.js b/scripts/rename.js index b1c38aba..545b6ad0 100644 --- a/scripts/rename.js +++ b/scripts/rename.js @@ -2,4 +2,58 @@ const path = require('path') const fs = require('fs-extra') -const resolve = dir => path.resolve(__dirname, dir); \ No newline at end of file +const resolve = dir => path.resolve(__dirname, dir); + + + +function getFiles(rootPath, limit) { + return fs.readdirSync(rootPath) + .filter(file => (file.endsWith('.md') && /^\d+_/.test(file) && +file.split('_')[0] >= limit)) + .sort((a, b) => { + const a1 = +a.split('_')[0]; + const b1 = +b.split('_')[0]; + if (a1 < b1) return -1; + if (a1 > b1) return 1; + return 0; + }); +}; + + + +function add(dirPath, limit) { + const rootPath = resolve(dirPath); + const files = getFiles(rootPath, limit); + for (const file of files) { + const arr = /(^\d+)_(.*)/.exec(file); + const entryPath = path.resolve(rootPath, file); + const outputName = `${ + arr[1] + 1}_${arr[2]}`; + const outputPath = path.resolve(rootPath, outputName); + fs.renameSync(entryPath, outputPath); + } +} + +function multiple(dirPath, limit) { + const rootPath = resolve(dirPath); + const files = getFiles(rootPath, limit); + for (const file of files) { + const arr = /(^\d+)_(.*)/.exec(file); + const entryPath = path.resolve(rootPath, file); + const outputName = `${ + arr[1] - 1}_${arr[2]}`; + const outputPath = path.resolve(rootPath, outputName); + fs.renameSync(entryPath, outputPath); + } +} + +function remove(dirPath, limit) { + const rootPath = resolve(dirPath); + const files = getFiles(rootPath, limit); + for (const file of files) { + const arr = /(^\d+)_(.*)/.exec(file); + const entryPath = path.resolve(rootPath, file); + const outputName = `${arr[2]}`; + const outputPath = path.resolve(rootPath, outputName); + fs.renameSync(entryPath, outputPath); + } +} + +remove('../md/Java框架/Spring', 13); \ No newline at end of file