解决 fatal: refusing to merge unrelated histories

Git 的报错

一、fatal: refusing to merge unrelated histories

新建了一个仓库之后,把本地仓库进行关联提交、拉取的时候,出现了如下错误:

ankobot@DESKTOP-9IUDMKP MINGW64 /e/workspace/firmware_upload/firmware_upload (master)
$ git pull
fatal: refusing to merge unrelated histories

二、解决方案

在你操作命令后面加 –allow-unrelated-histories
例如:

git merge master --allow-unrelated-histories
$ git pull --allow-unrelated-histories
CONFLICT (add/add): Merge conflict in .gitignore
Auto-merging .gitignore
Automatic merge failed; fix conflicts and then commit the result.

我这里由于使用了官方的 .gitignore 自动合并失败,需要手动合并之后再进行 add、commit 即可

如果你是git pull或者git push报fatal: refusing to merge unrelated histories
同理:
git pull origin master –allow-unrelated-histories / git pull –allow-unrelated-histories
等等,就是这样完美的解决!

Spring boot jackson序列化实体类属性大小写问题

查了一下,原来com.fasterxml.jackson搞的鬼,我的问题是实体类有一个属性叫UDID,但是接口返回的JSON变成了小写udid。

使用@JsonProperty(“UDID”)注解可以完美解决调这个问题,例子:

@JsonProperty("UDID")
private String UDID;

放在geter方法同样有效:

@JsonProperty("UDID")
public String getUDID() {
    return UDID;
}

建议是放在geter方法上,如果放在属性上,它会出现两个UDID,一个是大写的,一个小写的。

那么放在方法上呢,就不会出现这个问题。

爱因斯坦:《我的世界观》

Maven编译指定module

今天在项目里新添加了一个Module, 但是在jenkins编译的时候会将这个Module也编译, 问题是这个Module根本不需要编译而且巨慢。

因此我只想编译指定模块 ModuleA以及它依赖的必须模块, 以下是相关的命令

-am --also-make 同时构建所列模块的依赖模块;
-amd -also-make-dependents 同时构建依赖于所列模块的模块;
-pl --projects <arg> 构建制定的模块,模块间用逗号分隔;
-rf -resume-from <arg> 从指定的模块恢复反应堆。
    <modules>
        <module>ModuleA</module>
        <module>ModuleB</module>
        <module>ModuleC</module>
        <module>ModuleD</module>
        <module>ModuleE</module>
    </modules>

首先查看一下依赖关系

mvn dependency:tree

当不然不是上面这句, 所有的依赖关系太复杂了, 会列出依赖的所有的包

自己打开各个module的pom看一下互相之间的依赖就行

假如只想编译ModuleB及其依赖的模块, 那么在编译的时候

mvn clean install -pl ModuleB -am

假设Module依赖了A和C, 那么在编译的时候就只会编译A B C三个模块~

如果ModuleD依赖了B, 然后在编译的时候使用了-amd的话, 那么ModuleD也会被编译, 这个意思就是编译依赖了所列模块的模块

mvn clean install -pl ModuleB -am -amd

使用上面的命令会同时编译 A B C D ~

-rf 选项用于选择起始位置(发现结合-rf的时候, -am和-amd是需要后置的)

假设ModuleA和ModuleC都依赖ModuleB, 那么如果在ModuleB截断, 整个流程不会变, 如果在ModuleA截断, 那么只会从ModuleA开始执行后面的构建流程。

mvn install -pl ModuleB -am -amd -rf ModuleA

上面的命令是从ModuleA开始截断的

总结

一般来说经常用到的命令, 你想编译的Module: ModuleX

mvn clean install ModuleX -am
mvn clean package install -pl 模块的名称 -am

angular directives scope

以前学过,但是忘记了,所以重新记录一篇文章。

directive中的restrict属性,来决定这个指令是作为标签(E)、属性(A)、属性值(C)、还是注释(M)。

1、false(默认值):直接使用父scope。比较“危险”。

可以理解成指令内部并没有一个新的scope,它和指令以外的代码共享同一个scope。

2、true:继承父scope

 

 

3、{ }:创建一个新的“隔离”scope,但仍可与父scope通信

隔离的scope,通常用于创建可复用的指令,也就是它不用管父scope中的model。然而虽然说是“隔离”,但通常我们还是需要让这个子scope跟父scope中的变量进行绑定。绑定的策略有3种:

  • @:单向绑定,外部scope能够影响内部scope,但反过来不成立
  • =:双向绑定,外部scope和内部scope的model能够相互改变
  • &:把内部scope的函数的返回值和外部scope的任何属性绑定起来
(1)@:单向绑定

示例代码:

<body ng-app="watchDemo">
<!--外部scope-->
<p>父scope:<input type="text" ng-model="input"></p>
<!--内部隔离scope-->
<my-directive my-text="{{input}}"></my-directive>

<script>
    var app = angular.module('watchDemo', []);
    app.directive('myDirective', function () {
        return {
            restrict: 'E',
            replace: true,
            template: '<p>自定义指令scope:<input type="text" ng-model="myText"></p>',
            scope: {
                myText: '@'
            }
        }
    });
</script>
</body>

(2)=:双向绑定

示例代码:

<body ng-app="watchDemo">
<!--外部scope-->
<p>父scope:<input type="text" ng-model="input"></p>

<!--内部隔离scope-->
<!--注意这里,因为是双向绑定,所以这里不要“{{}}”这个符号-->
<my-directive my-text="input"></my-directive>

<script>
    var app = angular.module('watchDemo', []);
    app.directive('myDirective', function () {
        return {
            restrict: 'E',
            replace: true,
            template: '<p>自定义指令scope:<input type="text" ng-model="myText"></p>',
            scope: {
                myText: '=' // 这里改成了双向绑定
            }
        }
    });
</script>
</body>
(3)&:内部scope的函数返回值和外部scope绑定

 

<body ng-app="watchDemo">
<!--外部scope-->
<p>父scope:<input type="text" ng-model="input"></p>

<!--内部隔离scope-->
<!--注意这里,函数名字也要用 连字符命名法-->
<my-directive get-my-text="input"></my-directive>

<script>
    var app = angular.module('watchDemo', []);
    app.directive('myDirective', function () {
        return {
            restrict: 'E',
            replace: true,
            template: '<p>结果:{{ getMyText() }}</p>',
            scope: {
                getMyText: '&' // 这里改成了函数返回值的绑定
            }
        }
    });
</script>
</body>
11213141516118
 
Copyright © 2008-2021 lanxinbase.com Rights Reserved. | 粤ICP备14086738号-3 |