xyz327

hakuna matata

spring-boot-starter-web依赖了spring-boot-starter-logging默认是使用logback的实现。
spring-boot默认的日志输出设置
resources目录下添加logback.xml内容如下

1
2
3
4
5
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml" />
<logger name="cn.xyz327" level="debug"/>
</configuration>

设置后就可以在代码中使用org.slf4j.Logger了,日志的输出格式采用spring-boot默认的格式

全角字符

存入全角的字母,然后用模糊查询 查询不出来..暂时先把全角改为半角…

事物隔离级别

今天把程序发布到线上环境时,插入数据时mysql直接报错

Cannot execute statement: binlogging impossible since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-logging. InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED.

百度一番,说问题是因为我程序插入数据时开启了事物
mysql默认的binlog_format是STATEMENT,而在READ COMMITTED或READ UNCOMMITTED隔离级别下,innodb只能使用的binlog_format是ROW。
我程序事物使用的隔离级别默认为READ_COMMINTED

阅读全文 »

loopback PersistedModel 的方法与rest api对应表

model的方法名 HTTP Method restApi url 说明
create POST /Model
upsert PATCH /Model
upsert PUT /Model
exists GET /Model/:id/exists
findById GET /Model/:id 查找对应id的Model
prototype.updateAttributes PATCH /Model/:id
prototype.updateAttributes PUT /Model/:id
destroyById/deleteById DELETE /Model/:id
exists HEAD /Model/:id
find GET /Model
findOne GET /Model/findOne
count GET /Model/count
createChangeStream GET /Model/chage-stream
createChangeStream POST /Model/chage-stream
replaceById POST /Model/:id/replace
replaceOrCreate POST /Model/replaceOrCreate
updateAll POST /Model/update
upsertWithWhere POST /Model/upsertWithWhere

关系模型的部分方法与rest api 对应表 更多说明参考 官方文档

model的关联对象的方法名 HTTP Method restApi url 说明
__get__attr GET /Model/:id/attr 查找对应id的Model下的attr数据
__create__attr POST /Model/:id/attr 创建一条对应id的Model下的attr数据
__delete__attr DELETE /Model/:id/attr 删除对应id的Model下的所有attr数据
__count__attr GET /Model/:id/attr/count 查找对应id的Model下的attr数据数量
__findById__attr GET /Model/:id/attr/:attrId 查找对应id的Model下的id为attrId的数据
__destroyById__attr DELETE /Model/:id/attr/:attrId 删除对应id的Model下的id为attrId的数据
__updateById__attr PUT /Model/:id/attr/:attrId 更新对应id的Model下的id为attrId的数据
__exists__attr HEAD /Model/:id/attr/rel/:attrId 检查对应id的Model下的id为attrId的数据(貌似没什么用)
__link__attr PUT /Model/:id/attr/rel/:attrId 新增Model与attr的中间数据 (多对多关系)
__unlink__attr DELETE /Model/:id/attr/rel/:attrId 删除Model与attr的中间数据 (多对多关系)

loopback是一个用来构建restfulAPI的轻量级的nodejs框架 基于express
官网 github

阅读全文 »

开始

设置git

1
2
$ git config --global user.name "xyz327"   //给自己起个用户名
$ git config --globla user.email "xyz327@outlook.com" //填写自己的邮箱

解决冲突

  1. 放弃本地修改,直接更新远端内容
    1
    2
    3
    4
    git fetch --all
    git reset --hard origin/master
    # git fetch 只是下载远程的库的内容,
    # 不做任何的合并 git reset 把HEAD指向刚刚下载的最新的版本

针对NexT.Pisces

固定边侧栏

修改

theme/next/source/js/src/schemes/pisces.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
$(document).ready(function () {
var $headerInner = $('.header-inner');
var $sidebar = $('#sidebar');
$sidebar.show();
// 固定顶部黑条
$('.headband').css({'position':'fixed', top:0,width:'100%',zIndex:1});
$headerInner.css({top:0})
var affix = function() {
var sidebarTop = $headerInner.height() + 10;
$('#sidebar').css({ 'margin-top': sidebarTop }).affix();
if (document.body.clientWidth < 975) {
$headerInner.css({position: 'static'})
} else {
$headerInner.css({position: 'fixed'})
}
};
affix()
$(window).on('resize', function(){
affix()
});
});

修改文章页面滚动站点信息栏会覆盖菜单栏

阅读全文 »

考虑使用静态工厂方法代替构造器

静态工厂方法相比构造器的优势

  1. 它们有名称_。根据方法名字可以清楚的知道可以获得什么样子的对象
  2. 不必再每次调用的时候都创建一个新对象。
  3. 它们可以返回原返回类型的任何子类型的对象。
  4. 在创建参数化类型实例的时候,它们是代码变得更加简洁
阅读全文 »

Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.

Quick Start

Create a new post

1
$ hexo new "My New Post"

More info: Writing

Run server

阅读全文 »