From cec89b67a67910607dcc64909b736e1b064ed7db Mon Sep 17 00:00:00 2001 From: fxb Date: Sat, 10 Nov 2018 17:10:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E6=A1=A3=E4=BF=A1=E6=81=AF=E6=95=B4?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../linux下mongodb的安装与配置(非atp).md | 2 +- spring/1.spring基础.md | 5 +- spring/2.最小化XML配置.md | 5 +- spring/3.面向切面的Spring.md | 6 +- .../springboot搭建/springboot搭建.md | 4 +- .../springsecurity/springboot+security整合1.md | 5 +- .../springsecurity/springboot+security整合2.md | 5 +- .../springsecurity/springboot+security整合3.md | 5 +- .../websocket/springboot整合websocket.md | 5 +- ...ybatis.md => springboot整合mybatis(xml和注解).md} | 727 +++++++++--------- .../消息队列/springboot整合activeMQ(1).md | 7 +- .../消息队列/springboot整合activeMQ(2).md | 6 +- .../读写分离配置/springboot配置读写分离.md | 5 +- 其他各种/git crlf、lf自动转换引起的问题.md | 5 +- 其他各种/java导出EXCEL文件.md | 5 +- 其他各种/正则表达式在密码匹配中的使用.md | 5 +- 其他各种/毕设.md | 5 +- 数据库/分布式事务1.md | 5 +- 数据库/数据库事务四个特性及隔离级别.md | 5 +- 网络/nat模式虚拟机主机相互ping通.md | 5 +- 20 files changed, 440 insertions(+), 382 deletions(-) rename springboot系列/数据库/{springboot整合mybatis.md => springboot整合mybatis(xml和注解).md} (96%) diff --git a/linux/软件安装/linux下mongodb的安装与配置(非atp).md b/linux/软件安装/linux下mongodb的安装与配置(非atp).md index df59d7a..bcf92c0 100644 --- a/linux/软件安装/linux下mongodb的安装与配置(非atp).md +++ b/linux/软件安装/linux下mongodb的安装与配置(非atp).md @@ -1,5 +1,5 @@ [id]: 2018-11-09 -[type]: 软件使用 +[type]: 软件 [tag]: linux,mongodb   首先到官网下载安装包,官网地址如下:[点击跳转](https://www.mongodb.com/download-center/community),选中合适的版本,下面会出现下载链接,然后使用 wget url 下载到当前文件夹下。mongodb 4.04 ubuntu18.04 64 下载命令如下: diff --git a/spring/1.spring基础.md b/spring/1.spring基础.md index 975d04d..405ce70 100644 --- a/spring/1.spring基础.md +++ b/spring/1.spring基础.md @@ -1,4 +1,7 @@ -[id]: 62ee59a0d6c111e8aa858b6a40460626 +[id]:2018-08-12_1 +[type]:javaee +[tag]:java,spring +   spring是为了解决企业级应用开发的复杂性而创建的,spring最根本的使命是:简化Java开发。为降低开发复杂性有以下四种关键策略。 - 基于POJO的轻量级和最小侵入性编程 diff --git a/spring/2.最小化XML配置.md b/spring/2.最小化XML配置.md index e7a6f0c..f21963e 100644 --- a/spring/2.最小化XML配置.md +++ b/spring/2.最小化XML配置.md @@ -1,4 +1,7 @@ -[id]: 6d17f940d6c111e8aa858b6a40460626 +[id]:2018-08-12_2 +[type]:javaee +[tag]:java,spring + ## 一、自动装配 ### 1、四种类型的自动装配 diff --git a/spring/3.面向切面的Spring.md b/spring/3.面向切面的Spring.md index 8250711..98297da 100644 --- a/spring/3.面向切面的Spring.md +++ b/spring/3.面向切面的Spring.md @@ -1,6 +1,10 @@ -[id]: 6f135410d6c111e8aa858b6a40460626 +[id]:2018-08-12_3 +[type]:javaee +[tag]:java,spring + ## 一.面向切面编程 +   Spring的基础是IOC和AOP,前面两节对IOC和DI做了简单总结,这里再对AOP进行一个学习总结,Spring基础就算有一个初步了解了。   在软件开发中,我们可能需要一些跟业务无关但是又必须做的东西,比如日志,事务等,这些分布于应用中多处的功能被称为横切关注点,通常横切关注点从概念上是与应用的业务逻辑相分离的。如何将这些横切关注点与业务逻辑在代码层面进行分离,是面向切面编程(**AOP**)所要解决的。 diff --git a/springboot系列/springboot搭建/springboot搭建.md b/springboot系列/springboot搭建/springboot搭建.md index 6d31421..d5e9a4d 100644 --- a/springboot系列/springboot搭建/springboot搭建.md +++ b/springboot系列/springboot搭建/springboot搭建.md @@ -1,4 +1,6 @@ -[id]: 729b1b40d6c111e8aa858b6a40460626 +[id]:2018-08-13 +[type]:javaee +[tag]:java,spring,springboot   前面的博客有说到spring boot搭建见另一篇博文,其实那篇博文还没写,现在来填个坑。我们使用spring initializr来构建,idea和eclipse都支持这种方式,构建过程类似,这里以idea为例,详细记录构建过程。 ###1.选择spring initializr diff --git a/springboot系列/springsecurity/springboot+security整合1.md b/springboot系列/springsecurity/springboot+security整合1.md index 698fc5b..758a848 100644 --- a/springboot系列/springsecurity/springboot+security整合1.md +++ b/springboot系列/springsecurity/springboot+security整合1.md @@ -1,4 +1,7 @@ -[id]: 7a77bda0d6c111e8aa858b6a40460626 +[id]:2018-08-20 +[type]:javaee +[tag]:java,spring,springsecurity,scurity + **说明springboot版本2.0.3** ##一、 介绍 diff --git a/springboot系列/springsecurity/springboot+security整合2.md b/springboot系列/springsecurity/springboot+security整合2.md index 224ee6b..959c28d 100644 --- a/springboot系列/springsecurity/springboot+security整合2.md +++ b/springboot系列/springsecurity/springboot+security整合2.md @@ -1,4 +1,7 @@ -[id]: 7c140880d6c111e8aa858b6a40460626 +[id]:2018-08-21 +[type]:javaee +[tag]:java,spring,springsecurity,scurity +   紧接着上一篇,上一篇中登录验证都由security帮助我们完成了,如果我们想要增加一个验证码登录或者其它的自定义校验就没办法了,因此这一篇讲解如何实现这个功能。 ##一、 实现自定义登录校验类 diff --git a/springboot系列/springsecurity/springboot+security整合3.md b/springboot系列/springsecurity/springboot+security整合3.md index 1a121df..e78f29e 100644 --- a/springboot系列/springsecurity/springboot+security整合3.md +++ b/springboot系列/springsecurity/springboot+security整合3.md @@ -1,4 +1,7 @@ -[id]: 7cfc1e90d6c111e8aa858b6a40460626 +[id]:2018-08-22 +[type]:javaee +[tag]:java,spring,springsecurity,scurity +   这篇讲解如何自定义鉴权过程,实现根据数据库查询出的url和method是否匹配当前请求的url和method来决定有没有权限。security鉴权过程如下: ![鉴权流程](./picFolder/pic2.png) diff --git a/springboot系列/websocket/springboot整合websocket.md b/springboot系列/websocket/springboot整合websocket.md index ebb6c69..6afe5b6 100644 --- a/springboot系列/websocket/springboot整合websocket.md +++ b/springboot系列/websocket/springboot整合websocket.md @@ -1,4 +1,7 @@ -[id]: 7e229d30d6c111e8aa858b6a40460626 +[id]:2018-08-25 +[type]:javaee +[tag]:java,spring,websocket +

一、背景

  我们都知道http协议只能浏览器单方面向服务器发起请求获得响应,服务器不能主动向浏览器推送消息。想要实现浏览器的主动推送有两种主流实现方式: diff --git a/springboot系列/数据库/springboot整合mybatis.md b/springboot系列/数据库/springboot整合mybatis(xml和注解).md similarity index 96% rename from springboot系列/数据库/springboot整合mybatis.md rename to springboot系列/数据库/springboot整合mybatis(xml和注解).md index 1c172bc..033fc9e 100644 --- a/springboot系列/数据库/springboot整合mybatis.md +++ b/springboot系列/数据库/springboot整合mybatis(xml和注解).md @@ -1,363 +1,366 @@ -[id]: 818f3b40d6c111e8aa858b6a40460626 -## 写在前面 - -​ 刚毕业的第一份工作是java开发,项目中需要用到mybatis,特此记录学习过程,这只是一个简单demo,mybatis用法很多不可能全部写出来,有更复杂的需求建议查看mybatis的官方中文文档,[点击跳转](http://www.mybatis.org/mybatis-3/zh/index.html)。下面时项目环境/版本。 - -- 开发工具:IDEA -- jdk版本:1.8 -- springboot版本:2.03 - -其他依赖版本见下面pom.xml: - -```xml - - - 4.0.0 - - com.example - mybatis-test - 0.0.1-SNAPSHOT - jar - - mybatis-test - Demo project for Spring Boot - - - org.springframework.boot - spring-boot-starter-parent - 2.0.3.RELEASE - - - - - UTF-8 - UTF-8 - 1.8 - - - - - org.springframework.boot - spring-boot-starter-web - - - mysql - mysql-connector-java - runtime - - - - org.mybatis.spring.boot - mybatis-spring-boot-starter - 1.3.2 - - - - com.alibaba - druid-spring-boot-starter - 1.1.9 - - - - com.github.pagehelper - pagehelper-spring-boot-starter - 1.2.5 - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - -``` - -## 1.创建项目 - -​ 使用idea中的spring initializr生成maven项目,项目命令为mybatis-test,选择web,mysql,mybatis依赖,即可成功。(详细过程不赘述,如有需要学习springboot创建过程,可参考[这篇文章]()。 - -​ 然后依照上面的pom文件,补齐缺少的依赖。接着创建包entity,service和mybatis映射文件夹mapper,创建。为了方便配置将application.properties改成application.yml。由于我们时REST接口,故不需要static和templates目录。修改完毕后的项目结构如下: - -![项目结构](./picFolder/pic1.png) - -​ 修改启动类,增加`@MapperScan("com.example.mybatistest.dao") `,以自动扫描dao目录,避免每个dao都手动加`@Mapper`注解。代码如下: - -```java -@SpringBootApplication -@MapperScan("com.example.mybatistest.dao") -public class MybatisTestApplication { - public static void main(String[] args) { - SpringApplication.run(MybatisTestApplication.class, args); - } -} -``` - - 修改application.yml,配置项目,代码如下: - -```yml -mybatis: - #对应实体类路径 - type-aliases-package: com.example.mybatistest.entity - #对应mapper映射文件路径 - mapper-locations: classpath:mapper/*.xml - -#pagehelper物理分页配置 -pagehelper: - helper-dialect: mysql - reasonable: true - support-methods-arguments: true - params: count=countSql - returnPageInfo: check - -server: - port: 8081 - -spring: - datasource: - name: mysqlTest - type: com.alibaba.druid.pool.DruidDataSource - #druid连接池相关配置 - druid: - #监控拦截统计的filters - filters: stat - driver-class-name: com.mysql.jdbc.Driver - url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=true - username: root - password: 123456 - #配置初始化大小,最小,最大 - initial-size: 1 - min-idle: 1 - max-active: 20 - #获取连接等待超时时间 - max-wait: 6000 - #间隔多久检测一次需要关闭的空闲连接 - time-between-eviction-runs-millis: 60000 - #一个连接在池中的最小生存时间 - min-evictable-idle-time-millis: 300000 - #打开PSCache,并指定每个连接上PSCache的大小。oracle设置为true,mysql设置为false。分库分表设置较多推荐设置 - pool-prepared-statements: false - max-pool-prepared-statement-per-connection-size: 20 - http: - encoding: - charset: utf-8 - enabled: true -``` - -## 2.编写代码 - -​ 首先创建数据表,sql语句如下: - -```sql -CREATE TABLE `user` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) NOT NULL, - `age` tinyint(4) NOT NULL DEFAULT '0', - `password` varchar(255) NOT NULL DEFAULT '123456', - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8; -``` - -​ 然后在entity包中创建实体类User.java - -```java -public class User { - private int id; - private String name; - private int age; - private String password; - - public User(int id, String name, int age, String password) { - this.id = id; - this.name = name; - this.age = age; - this.password = password; - } - public User(){} - //getter setter自行添加 -} -``` - -​ 在dao包下创建UserDao.java - -```java -public interface UserDao { - //插入用户 - int insert(User user); - //根据id查询 - User selectById(String id); - //查询所有 - List selectAll(); -} -``` - -​ 在mapper文件夹下创建UserMapper.xml,具体的xml编写方法查看文首的官方文档。 - -```xml - - - - - user - - - id,name,age,password - - - - INSERT INTO - - name,password, - - age - - - - #{name,jdbcType=VARCHAR},#{password}, - - #{age} - - - - - - - - -``` - -​ 至此使用mybatis的代码编写完了,之后要用时调用dao接口中的方法即可。 - -## 3.测试 - -​ 我们通过编写service,controller然后使用postman进行测试。 - -​ 首先编写UserService.java,代码如下: - -```java -@Component -public class UserService { - - @Autowired - private UserDao userDao; - - public User getByUserId(String id){ - return userDao.selectById(id); - } - //获取全部用户 - public List getAll(){ - return userDao.selectAll(); - } - //测试分页 - public PageInfo getAll(int pageNum,int pageSize){ - PageHelper.startPage(pageNum,pageSize); - List users = userDao.selectAll(); - System.out.println(users.size()); - PageInfo result = new PageInfo<>(users); - return result; - } - - public int insert(User user){ - return userDao.insert(user); - } - -} -``` - -​ 编写UserController.java - -```java -@RestController -public class UserController { - - @Autowired - private UserService userService; - - @GetMapping("/user/{userId}") - public User getUser(@PathVariable String userId){ - return userService.getByUserId(userId); - } - - @GetMapping("/user") - public List getAll(){ - return userService.getAll(); - } - - @GetMapping("/user/page/{pageNum}") - public Object getPage(@PathVariable int pageNum, - @RequestParam(name = "pageSize",required = false,defaultValue = "10") int pageSize){ - return userService.getAll(pageNum,pageSize); - } - - @PostMapping("/user") - public Object addOne(User user){ - userService.insert(user); - return user; - } -} -``` - -​ 启动项目,通过postman进行请求测试,测试结果如下: - -- 插入数据: - -![插入](./picFolder/pic2.png) - -- 查询数据 - -![查询](./picFolder/pic3.png) - - - -- 分页查询 - - ![分页查询](./picFolder/pic4.png) - - - -## 4.注解编写sql - -​ 上面使用的是xml方式编写sql代码,其实mybatis也支持在注解中编写sql,这样可以避免编写复杂的xml查询文件,但同时也将sql语句耦合到了代码中,也不易实现复杂查询,因此多用于简单sql语句的编写。 - -​ 要使用注解首先将applicaton.yml配置文件中的`mapper-locations: classpath:mapper/*.xml`注释掉。然后在UserDao.java中加入sql注解,代码如下: - -```java -public interface UserDao { - //插入用户 - @Insert("insert into user(name,age,password) value(#{name},#{age},#{password})") - @Options(useGeneratedKeys=true,keyColumn="id",keyProperty="id") - int insert(User user); - //根据id查询 - @Select("select * from user where id=#{id}") - User selectById(String id); - //查询所有 - @Select("select * from user") - List selectAll(); -} -``` - -然后重新启动项目测试,测试结果跟上面完全一样。 - -``` -如果对你有帮助记得点赞、收藏哦! +[id]:2018-09-01 +[type]:javaee +[tag]:java,spring,mysql,mybatis,xml + +## 写在前面 + +​ 刚毕业的第一份工作是java开发,项目中需要用到mybatis,特此记录学习过程,这只是一个简单demo,mybatis用法很多不可能全部写出来,有更复杂的需求建议查看mybatis的官方中文文档,[点击跳转](http://www.mybatis.org/mybatis-3/zh/index.html)。下面时项目环境/版本。 + +- 开发工具:IDEA +- jdk版本:1.8 +- springboot版本:2.03 + +其他依赖版本见下面pom.xml: + +```xml + + + 4.0.0 + + com.example + mybatis-test + 0.0.1-SNAPSHOT + jar + + mybatis-test + Demo project for Spring Boot + + + org.springframework.boot + spring-boot-starter-parent + 2.0.3.RELEASE + + + + + UTF-8 + UTF-8 + 1.8 + + + + + org.springframework.boot + spring-boot-starter-web + + + mysql + mysql-connector-java + runtime + + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + 1.3.2 + + + + com.alibaba + druid-spring-boot-starter + 1.1.9 + + + + com.github.pagehelper + pagehelper-spring-boot-starter + 1.2.5 + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + +``` + +## 1.创建项目 + +​ 使用idea中的spring initializr生成maven项目,项目命令为mybatis-test,选择web,mysql,mybatis依赖,即可成功。(详细过程不赘述,如有需要学习springboot创建过程,可参考[这篇文章]()。 + +​ 然后依照上面的pom文件,补齐缺少的依赖。接着创建包entity,service和mybatis映射文件夹mapper,创建。为了方便配置将application.properties改成application.yml。由于我们时REST接口,故不需要static和templates目录。修改完毕后的项目结构如下: + +![项目结构](./picFolder/pic1.png) + +​ 修改启动类,增加`@MapperScan("com.example.mybatistest.dao") `,以自动扫描dao目录,避免每个dao都手动加`@Mapper`注解。代码如下: + +```java +@SpringBootApplication +@MapperScan("com.example.mybatistest.dao") +public class MybatisTestApplication { + public static void main(String[] args) { + SpringApplication.run(MybatisTestApplication.class, args); + } +} +``` + + 修改application.yml,配置项目,代码如下: + +```yml +mybatis: + #对应实体类路径 + type-aliases-package: com.example.mybatistest.entity + #对应mapper映射文件路径 + mapper-locations: classpath:mapper/*.xml + +#pagehelper物理分页配置 +pagehelper: + helper-dialect: mysql + reasonable: true + support-methods-arguments: true + params: count=countSql + returnPageInfo: check + +server: + port: 8081 + +spring: + datasource: + name: mysqlTest + type: com.alibaba.druid.pool.DruidDataSource + #druid连接池相关配置 + druid: + #监控拦截统计的filters + filters: stat + driver-class-name: com.mysql.jdbc.Driver + url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=true + username: root + password: 123456 + #配置初始化大小,最小,最大 + initial-size: 1 + min-idle: 1 + max-active: 20 + #获取连接等待超时时间 + max-wait: 6000 + #间隔多久检测一次需要关闭的空闲连接 + time-between-eviction-runs-millis: 60000 + #一个连接在池中的最小生存时间 + min-evictable-idle-time-millis: 300000 + #打开PSCache,并指定每个连接上PSCache的大小。oracle设置为true,mysql设置为false。分库分表设置较多推荐设置 + pool-prepared-statements: false + max-pool-prepared-statement-per-connection-size: 20 + http: + encoding: + charset: utf-8 + enabled: true +``` + +## 2.编写代码 + +​ 首先创建数据表,sql语句如下: + +```sql +CREATE TABLE `user` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(255) NOT NULL, + `age` tinyint(4) NOT NULL DEFAULT '0', + `password` varchar(255) NOT NULL DEFAULT '123456', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8; +``` + +​ 然后在entity包中创建实体类User.java + +```java +public class User { + private int id; + private String name; + private int age; + private String password; + + public User(int id, String name, int age, String password) { + this.id = id; + this.name = name; + this.age = age; + this.password = password; + } + public User(){} + //getter setter自行添加 +} +``` + +​ 在dao包下创建UserDao.java + +```java +public interface UserDao { + //插入用户 + int insert(User user); + //根据id查询 + User selectById(String id); + //查询所有 + List selectAll(); +} +``` + +​ 在mapper文件夹下创建UserMapper.xml,具体的xml编写方法查看文首的官方文档。 + +```xml + + + + + user + + + id,name,age,password + + + + INSERT INTO + + name,password, + + age + + + + #{name,jdbcType=VARCHAR},#{password}, + + #{age} + + + + + + + + +``` + +​ 至此使用mybatis的代码编写完了,之后要用时调用dao接口中的方法即可。 + +## 3.测试 + +​ 我们通过编写service,controller然后使用postman进行测试。 + +​ 首先编写UserService.java,代码如下: + +```java +@Component +public class UserService { + + @Autowired + private UserDao userDao; + + public User getByUserId(String id){ + return userDao.selectById(id); + } + //获取全部用户 + public List getAll(){ + return userDao.selectAll(); + } + //测试分页 + public PageInfo getAll(int pageNum,int pageSize){ + PageHelper.startPage(pageNum,pageSize); + List users = userDao.selectAll(); + System.out.println(users.size()); + PageInfo result = new PageInfo<>(users); + return result; + } + + public int insert(User user){ + return userDao.insert(user); + } + +} +``` + +​ 编写UserController.java + +```java +@RestController +public class UserController { + + @Autowired + private UserService userService; + + @GetMapping("/user/{userId}") + public User getUser(@PathVariable String userId){ + return userService.getByUserId(userId); + } + + @GetMapping("/user") + public List getAll(){ + return userService.getAll(); + } + + @GetMapping("/user/page/{pageNum}") + public Object getPage(@PathVariable int pageNum, + @RequestParam(name = "pageSize",required = false,defaultValue = "10") int pageSize){ + return userService.getAll(pageNum,pageSize); + } + + @PostMapping("/user") + public Object addOne(User user){ + userService.insert(user); + return user; + } +} +``` + +​ 启动项目,通过postman进行请求测试,测试结果如下: + +- 插入数据: + +![插入](./picFolder/pic2.png) + +- 查询数据 + +![查询](./picFolder/pic3.png) + + + +- 分页查询 + + ![分页查询](./picFolder/pic4.png) + + + +## 4.注解编写sql + +​ 上面使用的是xml方式编写sql代码,其实mybatis也支持在注解中编写sql,这样可以避免编写复杂的xml查询文件,但同时也将sql语句耦合到了代码中,也不易实现复杂查询,因此多用于简单sql语句的编写。 + +​ 要使用注解首先将applicaton.yml配置文件中的`mapper-locations: classpath:mapper/*.xml`注释掉。然后在UserDao.java中加入sql注解,代码如下: + +```java +public interface UserDao { + //插入用户 + @Insert("insert into user(name,age,password) value(#{name},#{age},#{password})") + @Options(useGeneratedKeys=true,keyColumn="id",keyProperty="id") + int insert(User user); + //根据id查询 + @Select("select * from user where id=#{id}") + User selectById(String id); + //查询所有 + @Select("select * from user") + List selectAll(); +} +``` + +然后重新启动项目测试,测试结果跟上面完全一样。 + +``` +如果对你有帮助记得点赞、收藏哦! ``` \ No newline at end of file diff --git a/springboot系列/消息队列/springboot整合activeMQ(1).md b/springboot系列/消息队列/springboot整合activeMQ(1).md index d229c91..9d47e9f 100644 --- a/springboot系列/消息队列/springboot整合activeMQ(1).md +++ b/springboot系列/消息队列/springboot整合activeMQ(1).md @@ -1,5 +1,8 @@ -[id]: 82f50cd0d6c111e8aa858b6a40460626 -#
springboot与activeMQ入门(1)
+[id]:2018-09-05 +[type]:javaee +[tag]:java,spring,springboot,activemq + + **说明:acitveMQ版本为:5.9.1,springboot版本为2.0.3**
## 一. 下载安装(windows)   官方下载地址:[点我跳转](http://activemq.apache.org/download-archives.html),选择windows安装包下载,然后解压,解压后运行bin目录下的**activemq.bat**启动服务,无报错即可启动成功。默认管理地址为:[localhost:8161/admin](localhost:8161/admin),默认管理员账号密码为**admin**/**admin**。 diff --git a/springboot系列/消息队列/springboot整合activeMQ(2).md b/springboot系列/消息队列/springboot整合activeMQ(2).md index d3ef2ef..85e8c4d 100644 --- a/springboot系列/消息队列/springboot整合activeMQ(2).md +++ b/springboot系列/消息队列/springboot整合activeMQ(2).md @@ -1,4 +1,8 @@ -[id]: 83e5d570d6c111e8aa858b6a40460626 +[id]:2018-09-06 +[type]:javaee +[tag]:java,spring,activemq + +   单个MQ节点总是不可靠的,一旦该节点出现故障,MQ服务就不可用了,势必会产生较大的损失。这里记录activeMQ如何开启主从备份,一旦master(主节点故障),slave(从节点)立即提供服务,实现原理是运行多个MQ使用同一个持久化数据源,这里以jdbc数据源为例。同一时间只有一个节点(节点A)能够抢到数据库的表锁,其他节点进入阻塞状态,一旦A发生错误崩溃,其他节点就会重新获取表锁,获取到锁的节点成为master,其他节点为slave,如果节点A重新启动,也将成为slave。 ​ 主从备份解决了单节点故障的问题,但是同一时间提供服务的只有一个master,显然是不能面对数据量的增长,所以需要一种横向拓展的集群方式来解决面临的问题。 diff --git a/springboot系列/读写分离配置/springboot配置读写分离.md b/springboot系列/读写分离配置/springboot配置读写分离.md index a4072fd..a80835e 100644 --- a/springboot系列/读写分离配置/springboot配置读写分离.md +++ b/springboot系列/读写分离配置/springboot配置读写分离.md @@ -1,4 +1,7 @@ -[id]: 876b52b0d6c111e8aa858b6a40460626 +[id]:2018-09-10 +[type]:javaee +[tag]:java,spring,springboot,mybatis,读写分离 +   近日工作任务较轻,有空学习学习技术,遂来研究如果实现读写分离。这里用博客记录下过程,一方面可备日后查看,同时也能分享给大家(网上的资料真的大都是抄来抄去,,还不带格式的,看的真心难受)。 [完整代码](https://github.com/FleyX/demo-project/tree/master/dxfl) diff --git a/其他各种/git crlf、lf自动转换引起的问题.md b/其他各种/git crlf、lf自动转换引起的问题.md index 250eeed..69bca0b 100644 --- a/其他各种/git crlf、lf自动转换引起的问题.md +++ b/其他各种/git crlf、lf自动转换引起的问题.md @@ -1,4 +1,7 @@ -[id]: 88926d90d6c111e8aa858b6a40460626 +[id]:2018-09-20 +[type]:软件 +[tag]:git,crlf,lf +   项目组最近加了一个新功能到代码中,使用flyway记录数据库版本变更,,,该工具会记录每次数据库结构的修改并生成sql文件存在指定目录上(当然必须用它来变更数据库,外部的变更它是无法感知的),然后每次启动时flyway会检查使用的数据库和当前项目代码中的sql变更版本是否一致,一致正常启动,不一致中如果是数据库落后将会更新数据库(这样能够保证代码在任何地方运行数据库都是一致的),否则就报错了。数据库中有一张表记录版本信息,如下图: ![版本记录](./picFolder/版本记录.PNG),同时本地代码中也有一个文件夹保存每次操作的sql语句,如下图: diff --git a/其他各种/java导出EXCEL文件.md b/其他各种/java导出EXCEL文件.md index 242004f..b083ebe 100644 --- a/其他各种/java导出EXCEL文件.md +++ b/其他各种/java导出EXCEL文件.md @@ -1,4 +1,7 @@ -[id]: 8940d600d6c111e8aa858b6a40460626 +[id]:2018-09-22 +[type]:java +[tag]:java,reflect,excel,hssfworksheet + ## 一、背景   最近在java上做了一个EXCEL的导出功能,写了一个通用类,在这里分享分享,该类支持多sheet,且无需手动进行复杂的类型转换,只需提供三个参数即可: diff --git a/其他各种/正则表达式在密码匹配中的使用.md b/其他各种/正则表达式在密码匹配中的使用.md index c0d57d5..89cd90b 100644 --- a/其他各种/正则表达式在密码匹配中的使用.md +++ b/其他各种/正则表达式在密码匹配中的使用.md @@ -1,4 +1,7 @@ -[id]: 8b08c4c0d6c111e8aa858b6a40460626 +[id]:2018-09-30 +[type]:java +[tag]:java,正则,pattern + ##一、背景   今天领导让我写几个正则表达式来对密码做强度验证,听到写正则表达式内心是这样的感觉(哈哈,三分钟搞定,今天又可以打鱼了)。需求如下:密码组成只能是**数字**,**字母**,**英文可见半角符号**,然后需要如下4个表达式: diff --git a/其他各种/毕设.md b/其他各种/毕设.md index 44187a4..eb072a7 100644 --- a/其他各种/毕设.md +++ b/其他各种/毕设.md @@ -1,4 +1,7 @@ -[id]: 8c5ac030d6c111e8aa858b6a40460626 +[id]:2018-10-01 +[type]:项目 +[tag]:node,vue,element-ui,axios,koa,redis,mysql +   毕业才刚刚两个多月而已,现在想想大学生活是那么的遥不可及,感觉已经过了好久好久,社会了两个月才明白学校的好啊。。。额,扯远了,自从毕业开始就想找个时间写下毕设的记录总结,结果找了好久好久到今天才开始动笔。   我的毕业设计题目是:教学辅助系统的设计与实现,,是不是很俗。。。至于为啥是这个题目呢,完全是被导师坑了。。。。。 diff --git a/数据库/分布式事务1.md b/数据库/分布式事务1.md index 6e292fc..a51679b 100644 --- a/数据库/分布式事务1.md +++ b/数据库/分布式事务1.md @@ -1,4 +1,7 @@ -[id]: 8fdce210d6c111e8aa858b6a40460626 +[id]:2018-10-02 +[type]:数据库 +[tag]:acid,sql,分布式,事务 + ## 前言   分布式事务是企业集成中的一个技术难点,也是每一个分布式系统架构中都会涉及到的一个东西,特别是在微服务架构中,几乎是无法避免的。 diff --git a/数据库/数据库事务四个特性及隔离级别.md b/数据库/数据库事务四个特性及隔离级别.md index d12a510..554c9b0 100644 --- a/数据库/数据库事务四个特性及隔离级别.md +++ b/数据库/数据库事务四个特性及隔离级别.md @@ -1,4 +1,7 @@ -[id]: 912d2fd0d6c111e8aa858b6a40460626 +[id]:2018-10-03 +[type]:数据库 +[tag]:acid,sql,分布式,事务 + ## 一、 数据库事务四大特性ACID ### 1、 原子性(Atomicity) diff --git a/网络/nat模式虚拟机主机相互ping通.md b/网络/nat模式虚拟机主机相互ping通.md index 084ed11..a141476 100644 --- a/网络/nat模式虚拟机主机相互ping通.md +++ b/网络/nat模式虚拟机主机相互ping通.md @@ -1,4 +1,7 @@ -[id]: 92887a10d6c111e8aa858b6a40460626 +[id]:2018-08-04 +[type]:软件 +[tag]:vmware,vps,nat,ubuntu + ## 1、wmware设置   这篇记录下nat网络模式下虚拟机与主机的相互ping通。首先使用wmware建立一个ubuntu虚拟机,网络模式选择nat模式。然后点击虚拟网络编辑: