2019年4月29日星期一

修改ubuntu镜像源

修改配置文件(/etc/apt/sources.list)将安装源设置为国内的镜像,例如清华Ubuntu 16.04的镜像

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse

可选的ubuntu国内源:
阿里云:http://mirrors.aliyun.com/ubuntu/
清华:https://mirrors.tuna.tsinghua.edu.cn/ubuntu/

2019年4月16日星期二

java读取resources文件遇到的一个问题

spring中用applicationContext.getResources获取到Resource类实例之后,因为打包为jar之后resource文件在jar中,不在文件系统中,通过resource.getURI().getPath()为null,可以通过resource.getURL().getPath()获取到路径,比如:file:/Users/chenxiaoyu/project/target/project-1.0-SNAPSHOT.jar!/BOOT-INF/classes!/data/xx.txt

2019年4月9日星期二

非root用户修改hosts

参考https://unix.stackexchange.com/a/104511

vim ~/.hosts,增加hosts配置,比如:
hostname x.x.x.x

export HOSTALIASES=~/.hosts,done