文档信息整理

This commit is contained in:
fxb 2018-11-10 17:10:02 +08:00
parent 39bdf37640
commit cec89b67a6
20 changed files with 440 additions and 382 deletions

View File

@ -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 下载命令如下:

View File

@ -1,4 +1,7 @@
[id]: 62ee59a0d6c111e8aa858b6a40460626
[id]:2018-08-12_1
[type]:javaee
[tag]:java,spring
  spring是为了解决企业级应用开发的复杂性而创建的spring最根本的使命是简化Java开发。为降低开发复杂性有以下四种关键策略。
- 基于POJO的轻量级和最小侵入性编程

View File

@ -1,4 +1,7 @@
[id]: 6d17f940d6c111e8aa858b6a40460626
[id]:2018-08-12_2
[type]:javaee
[tag]:java,spring
## 一、自动装配
### 1、四种类型的自动装配

View File

@ -1,6 +1,10 @@
[id]: 6f135410d6c111e8aa858b6a40460626
[id]:2018-08-12_3
[type]:javaee
[tag]:java,spring
## 一.面向切面编程
  Spring的基础是IOC和AOP前面两节对IOC和DI做了简单总结这里再对AOP进行一个学习总结Spring基础就算有一个初步了解了。
  在软件开发中,我们可能需要一些跟业务无关但是又必须做的东西,比如日志,事务等,这些分布于应用中多处的功能被称为横切关注点,通常横切关注点从概念上是与应用的业务逻辑相分离的。如何将这些横切关注点与业务逻辑在代码层面进行分离,是面向切面编程(**AOP**)所要解决的。

View File

@ -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

View File

@ -1,4 +1,7 @@
[id]: 7a77bda0d6c111e8aa858b6a40460626
[id]:2018-08-20
[type]:javaee
[tag]:java,spring,springsecurity,scurity
**说明springboot版本2.0.3**
##一、 介绍

View File

@ -1,4 +1,7 @@
[id]: 7c140880d6c111e8aa858b6a40460626
[id]:2018-08-21
[type]:javaee
[tag]:java,spring,springsecurity,scurity
  紧接着上一篇上一篇中登录验证都由security帮助我们完成了如果我们想要增加一个验证码登录或者其它的自定义校验就没办法了因此这一篇讲解如何实现这个功能。
##一、 实现自定义登录校验类

View File

@ -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)

View File

@ -1,4 +1,7 @@
[id]: 7e229d30d6c111e8aa858b6a40460626
[id]:2018-08-25
[type]:javaee
[tag]:java,spring,websocket
<h3 id="#一、背景">一、背景</h3>
&emsp;&emsp;我们都知道http协议只能浏览器单方面向服务器发起请求获得响应服务器不能主动向浏览器推送消息。想要实现浏览器的主动推送有两种主流实现方式

View File

@ -1,363 +1,366 @@
[id]: 818f3b40d6c111e8aa858b6a40460626
## 写在前面
刚毕业的第一份工作是java开发项目中需要用到mybatis特此记录学习过程这只是一个简单demomybatis用法很多不可能全部写出来有更复杂的需求建议查看mybatis的官方中文文档[点击跳转](http://www.mybatis.org/mybatis-3/zh/index.html)。下面时项目环境/版本。
- 开发工具IDEA
- jdk版本1.8
- springboot版本2.03
其他依赖版本见下面pom.xml:
```xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>mybatis-test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>mybatis-test</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<!--mybatis依赖 -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.2</version>
</dependency>
<!--alibaba连接池依赖-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.9</version>
</dependency>
<!--分页依赖-->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
```
## 1.创建项目
使用idea中的spring initializr生成maven项目项目命令为mybatis-test选择webmysqlmybatis依赖即可成功。详细过程不赘述如有需要学习springboot创建过程可参考[这篇文章]()。
然后依照上面的pom文件补齐缺少的依赖。接着创建包entityservice和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设置为truemysql设置为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<User> selectAll();
}
```
在mapper文件夹下创建UserMapper.xml,具体的xml编写方法查看文首的官方文档。
```xml
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.example.mybatistest.dao.UserDao">
<sql id="BASE_TABLE">
user
</sql>
<sql id="BASE_COLUMN">
id,name,age,password
</sql>
<insert id="insert" parameterType="com.example.mybatistest.entity.User" useGeneratedKeys="true" keyProperty="id">
INSERT INTO <include refid="BASE_TABLE"/>
<trim prefix="(" suffix=")" suffixOverrides=",">
name,password,
<if test="age!=null">
age
</if>
</trim>
<trim prefix=" VALUE(" suffix=")" suffixOverrides=",">
#{name,jdbcType=VARCHAR},#{password},
<if test="age!=null">
#{age}
</if>
</trim>
</insert>
<select id="selectById" resultType="com.example.mybatistest.entity.User">
select
<include refid="BASE_COLUMN"/>
from
<include refid="BASE_TABLE"/>
where id=#{id}
</select>
<select id="selectAll" resultType="com.example.mybatistest.entity.User">
select
<include refid="BASE_COLUMN"/>
from
<include refid="BASE_TABLE"/>
</select>
</mapper>
```
至此使用mybatis的代码编写完了之后要用时调用dao接口中的方法即可。
## 3.测试
我们通过编写servicecontroller然后使用postman进行测试。
首先编写UserService.java,代码如下:
```java
@Component
public class UserService {
@Autowired
private UserDao userDao;
public User getByUserId(String id){
return userDao.selectById(id);
}
//获取全部用户
public List<User> getAll(){
return userDao.selectAll();
}
//测试分页
public PageInfo<User> getAll(int pageNum,int pageSize){
PageHelper.startPage(pageNum,pageSize);
List<User> users = userDao.selectAll();
System.out.println(users.size());
PageInfo<User> 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<User> 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<User> selectAll();
}
```
然后重新启动项目测试,测试结果跟上面完全一样。
```
如果对你有帮助记得点赞、收藏哦!
[id]:2018-09-01
[type]:javaee
[tag]:java,spring,mysql,mybatis,xml
## 写在前面
刚毕业的第一份工作是java开发项目中需要用到mybatis特此记录学习过程这只是一个简单demomybatis用法很多不可能全部写出来有更复杂的需求建议查看mybatis的官方中文文档[点击跳转](http://www.mybatis.org/mybatis-3/zh/index.html)。下面时项目环境/版本。
- 开发工具IDEA
- jdk版本1.8
- springboot版本2.03
其他依赖版本见下面pom.xml:
```xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>mybatis-test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>mybatis-test</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<!--mybatis依赖 -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.2</version>
</dependency>
<!--alibaba连接池依赖-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.9</version>
</dependency>
<!--分页依赖-->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
```
## 1.创建项目
使用idea中的spring initializr生成maven项目项目命令为mybatis-test选择webmysqlmybatis依赖即可成功。详细过程不赘述如有需要学习springboot创建过程可参考[这篇文章]()。
然后依照上面的pom文件补齐缺少的依赖。接着创建包entityservice和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设置为truemysql设置为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<User> selectAll();
}
```
在mapper文件夹下创建UserMapper.xml,具体的xml编写方法查看文首的官方文档。
```xml
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.example.mybatistest.dao.UserDao">
<sql id="BASE_TABLE">
user
</sql>
<sql id="BASE_COLUMN">
id,name,age,password
</sql>
<insert id="insert" parameterType="com.example.mybatistest.entity.User" useGeneratedKeys="true" keyProperty="id">
INSERT INTO <include refid="BASE_TABLE"/>
<trim prefix="(" suffix=")" suffixOverrides=",">
name,password,
<if test="age!=null">
age
</if>
</trim>
<trim prefix=" VALUE(" suffix=")" suffixOverrides=",">
#{name,jdbcType=VARCHAR},#{password},
<if test="age!=null">
#{age}
</if>
</trim>
</insert>
<select id="selectById" resultType="com.example.mybatistest.entity.User">
select
<include refid="BASE_COLUMN"/>
from
<include refid="BASE_TABLE"/>
where id=#{id}
</select>
<select id="selectAll" resultType="com.example.mybatistest.entity.User">
select
<include refid="BASE_COLUMN"/>
from
<include refid="BASE_TABLE"/>
</select>
</mapper>
```
至此使用mybatis的代码编写完了之后要用时调用dao接口中的方法即可。
## 3.测试
我们通过编写servicecontroller然后使用postman进行测试。
首先编写UserService.java,代码如下:
```java
@Component
public class UserService {
@Autowired
private UserDao userDao;
public User getByUserId(String id){
return userDao.selectById(id);
}
//获取全部用户
public List<User> getAll(){
return userDao.selectAll();
}
//测试分页
public PageInfo<User> getAll(int pageNum,int pageSize){
PageHelper.startPage(pageNum,pageSize);
List<User> users = userDao.selectAll();
System.out.println(users.size());
PageInfo<User> 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<User> 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<User> selectAll();
}
```
然后重新启动项目测试,测试结果跟上面完全一样。
```
如果对你有帮助记得点赞、收藏哦!
```

View File

@ -1,5 +1,8 @@
[id]: 82f50cd0d6c111e8aa858b6a40460626
# <div align="center">springboot与activeMQ入门1</div>
[id]:2018-09-05
[type]:javaee
[tag]:java,spring,springboot,activemq
**说明acitveMQ版本为5.9.1springboot版本为2.0.3**<br/>
## 一. 下载安装windows
&emsp;&emsp;官方下载地址:[点我跳转](http://activemq.apache.org/download-archives.html),选择windows安装包下载,然后解压解压后运行bin目录下的**activemq.bat**启动服务,无报错即可启动成功。默认管理地址为:[localhost:8161/admin](localhost:8161/admin),默认管理员账号密码为**admin**/**admin**。

View File

@ -1,4 +1,8 @@
[id]: 83e5d570d6c111e8aa858b6a40460626
[id]:2018-09-06
[type]:javaee
[tag]:java,spring,activemq
&emsp;&emsp;单个MQ节点总是不可靠的一旦该节点出现故障MQ服务就不可用了势必会产生较大的损失。这里记录activeMQ如何开启主从备份一旦master主节点故障slave从节点立即提供服务实现原理是运行多个MQ使用同一个持久化数据源这里以jdbc数据源为例。同一时间只有一个节点节点A能够抢到数据库的表锁其他节点进入阻塞状态一旦A发生错误崩溃其他节点就会重新获取表锁获取到锁的节点成为master其他节点为slave如果节点A重新启动也将成为slave。
主从备份解决了单节点故障的问题但是同一时间提供服务的只有一个master显然是不能面对数据量的增长所以需要一种横向拓展的集群方式来解决面临的问题。

View File

@ -1,4 +1,7 @@
[id]: 876b52b0d6c111e8aa858b6a40460626
[id]:2018-09-10
[type]:javaee
[tag]:java,spring,springboot,mybatis,读写分离
&emsp;&emsp;近日工作任务较轻,有空学习学习技术,遂来研究如果实现读写分离。这里用博客记录下过程,一方面可备日后查看,同时也能分享给大家(网上的资料真的大都是抄来抄去,,还不带格式的,看的真心难受)。
[完整代码](https://github.com/FleyX/demo-project/tree/master/dxfl)

View File

@ -1,4 +1,7 @@
[id]: 88926d90d6c111e8aa858b6a40460626
[id]:2018-09-20
[type]:软件
[tag]:git,crlf,lf
&emsp;&emsp;项目组最近加了一个新功能到代码中使用flyway记录数据库版本变更该工具会记录每次数据库结构的修改并生成sql文件存在指定目录上当然必须用它来变更数据库外部的变更它是无法感知的然后每次启动时flyway会检查使用的数据库和当前项目代码中的sql变更版本是否一致一致正常启动不一致中如果是数据库落后将会更新数据库这样能够保证代码在任何地方运行数据库都是一致的),否则就报错了。数据库中有一张表记录版本信息,如下图:
![版本记录](./picFolder/版本记录.PNG),同时本地代码中也有一个文件夹保存每次操作的sql语句如下图

View File

@ -1,4 +1,7 @@
[id]: 8940d600d6c111e8aa858b6a40460626
[id]:2018-09-22
[type]:java
[tag]:java,reflect,excel,hssfworksheet
## 一、背景
&emsp;&emsp;最近在java上做了一个EXCEL的导出功能写了一个通用类在这里分享分享该类支持多sheet且无需手动进行复杂的类型转换只需提供三个参数即可

View File

@ -1,4 +1,7 @@
[id]: 8b08c4c0d6c111e8aa858b6a40460626
[id]:2018-09-30
[type]:java
[tag]:java,正则,pattern
##一、背景
&emsp;&emsp;今天领导让我写几个正则表达式来对密码做强度验证,听到写正则表达式内心是这样的感觉(哈哈,三分钟搞定,今天又可以打鱼了)。需求如下:密码组成只能是**数字****字母****英文可见半角符号**然后需要如下4个表达式:

View File

@ -1,4 +1,7 @@
[id]: 8c5ac030d6c111e8aa858b6a40460626
[id]:2018-10-01
[type]:项目
[tag]:node,vue,element-ui,axios,koa,redis,mysql
&emsp;&emsp;毕业才刚刚两个多月而已,现在想想大学生活是那么的遥不可及,感觉已经过了好久好久,社会了两个月才明白学校的好啊。。。额,扯远了,自从毕业开始就想找个时间写下毕设的记录总结,结果找了好久好久到今天才开始动笔。
&emsp;&emsp;我的毕业设计题目是:教学辅助系统的设计与实现,,是不是很俗。。。至于为啥是这个题目呢,完全是被导师坑了。。。。。

View File

@ -1,4 +1,7 @@
[id]: 8fdce210d6c111e8aa858b6a40460626
[id]:2018-10-02
[type]:数据库
[tag]:acid,sql,分布式,事务
## 前言
&emsp;&emsp;分布式事务是企业集成中的一个技术难点,也是每一个分布式系统架构中都会涉及到的一个东西,特别是在微服务架构中,几乎是无法避免的。

View File

@ -1,4 +1,7 @@
[id]: 912d2fd0d6c111e8aa858b6a40460626
[id]:2018-10-03
[type]:数据库
[tag]:acid,sql,分布式,事务
## 一、 数据库事务四大特性ACID
### 1、 原子性Atomicity

View File

@ -1,4 +1,7 @@
[id]: 92887a10d6c111e8aa858b6a40460626
[id]:2018-08-04
[type]:软件
[tag]:vmware,vps,nat,ubuntu
## 1、wmware设置
&emsp;&emsp;这篇记录下nat网络模式下虚拟机与主机的相互ping通。首先使用wmware建立一个ubuntu虚拟机网络模式选择nat模式。然后点击虚拟网络编辑