首页 » 2019年5月

一次获取国内源失败,导致配置丢失。 wrong or NULL argument passed,解决办法是重置manjaro的mirro 源

1.报错如下

[shenfeng@Flame ~]$ sudo pacman -Sy
error: could not add server URL to database 'core':  (wrong or NULL argument passed)
error: could not add server URL to database 'extra':  (wrong or NULL argument passed)
error: could not add server URL to database 'community':  (wrong or NULL argument passed)
error: could not add server URL to database 'multilib':  (wrong or NULL argument passed)
:: Synchronizing package databases...
error: failed retrieving file 'core.db' from mirrors.163.com : The requested URL returned error: 404

2.让manjaro 帮我们找最快的一个

sudo pacman-mirrors --fasttrack 

3.然后

sudo pacman -Sy

附--参考文档---https://wiki.manjaro.org/index.php?title=Pacman-mirrors

对于webpack项目,debug方式很简单

1.打开config/index.js,找到这一行

devtool: 'cheap-module-eval-source-map',

2.改为:

 devtool: '#eval-source-map ',

2.然后想加断点的地方写上,即可

debugger

Error processing "launch": Error: Can't find Chrome

1.完整报错

Error processing "launch": Error: Can't find Chrome - install it or set the "runtimeExecutable" field in the launch config.
    at Object.errP (/home/shenfeng/.vscode/extensions/msjsdiag.debugger-for-chrome-4.11.3/node_modules/vscode-chrome-debug-core/out/src/utils.js:262:13)
    at ChromeDebugAdapter.<anonymous> (/home/shenfeng/.vscode/extensions/msjsdiag.debugger-for-chrome-4.11.3/out/src/chromeDebugAdapter.js:69:57)
    at Generator.next (<anonymous>)
    at /home/shenfeng/.vscode/extensions/msjsdiag.debugger-for-chrome-4.11.3/out/src/chromeDebugAdapter.js:10:71
    at new Promise (<anonymous>)
    at __awaiter (/home/shenfeng/.vscode/extensions/msjsdiag.debugger-for-chrome-4.11.3/out/src/chromeDebugAdapter.js:6:12)
    at launch.then (/home/shenfeng/.vscode/extensions/msjsdiag.debugger-for-chrome-4.11.3/out/src/chromeDebugAdapter.js:52:74)

2.这个是因为找不到chrome,用pacman查找位置

pacman -Ql google-chrome

3.lanch.json 配置

"runtimeExecutable": "/usr/bin/google-chrome-stable",

spring 自带的mongoRepository ,只能replace更新,即全量更新,我们可以自定义一个repository 方法。来做部分更新

1.解决思路就是生成一个map,对map中不为空的key生成update查询

Map<String, Object> objectMap = user.toMap();
    objectMap.values().removeIf(Objects::isNull);
    Update update = new Update();
    objectMap.forEach(update::set);

    return mongoOperations.findAndModify(
            Query.query(Criteria.where("_id").is(user.getId())), update, User.class);

2.而转换成map,可以用spring自带的jackson

ObjectMapper m = new ObjectMapper();
Map<String,Object> props = m.convertValue(myBean, Map.class);

3.需要注意的,对于基本类型的字段,有默认值的,所以推荐使用Object类型,如别用int 用Integer。null不占用mongodb的空间,即不会存储。所以从这方面也是好的。全部代码如下,注意笔者用的Reative版:

 public Mono<UpdateResult> updatePartial(MySeries mySeries) {
        if (null == mySeries || null == mySeries.getSrcId()) {
            return null;
        }
        ObjectMapper m = new ObjectMapper();
        Map<String, Object> objectMap = m.convertValue(mySeries, Map.class);
        objectMap.values().removeIf(o -> {
            if (null == o) {
                return true;
            }
            var cls = o.getClass();
            if (cls == ArrayList.class && ((ArrayList) o).size() <= 0) {
                return true;
            }
            if (cls == String.class && StringUtils.isEmpty(o)) {
                return true;
            }
      
            return false;
        });
        Update update = new Update();
        objectMap.forEach(update::set);
        Query q = new Query();
        q.addCriteria(Criteria.where("srcId").is(mySeries.getSrcId()));
        return template.updateFirst(q, update, MySeries.class);

    }