Linux修改主机名方法:
vi /etc/hosts
然后修改 127.0.0.1 localhost localhost.localdomain
可替换为 127.0.0.1 localhost peer1 peer2
这样就吧主机名字替换为 peer1 peer2 了。
然后使用 /etc/init.d/network restart 重启接口便可以生效。
在配置zuul时,提示报错HttpException: 没有到主机的路由 上网查得需要关闭linux防火墙,但是关闭掉防火墙后仍然报这个错误,
// @Scheduled(fixedDelay = 1000 * 60 * 30)
// @PostConstruct
private void getTokens() {
String result2 = HttpRequest.post("http://10.20.30.40:5000/v3/auth/tokens")
//超时,毫秒
.body("{\n" +
" \"auth\": {\n" +
" \"identity\": {\n" +
" \"methods\": [\n" +
" \"password\"\n" +
" ],\n" +
" \"password\": {\n" +
" \"user\": {\n" +
" \"name\": \"hanlp123\",\n" +
" \"domain\": {\n" +
" \"name\": \"Default\"\n" +
" },\n" +
" \"password\": \"Dksou@2020\"\n" +
" }\n" +
" }\n" +
" },\n" +
" \"scope\": {\n" +
" \"project\": {\n" +
" \t\"domain\": {\n" +
" \"name\": \"Default\"\n" +
" },\n" +
" \"name\": \"hanlp\"\n" +
" }\n" +
" }\n" +
" }\n" +
"}\n")
.timeout(20000)
.execute().header("x-subject-token");
tokens = result2;
}
将
// @Scheduled(fixedDelay = 1000 * 60 * 30) // @PostConstruct
这两行注解注释以后系统启动成功。
java 定时任务之一 @Scheduled注解(第一种方法)
被@PostConstruct修饰的方法会在服务器加载Servlet的时候运行,并且只会被服务器执行一次。PostConstruct在构造函数之后执行,init()方法之前执行。PreDestroy()方法在destroy()方法知性之后执行