配置 Spring Boot Admin报错。

配置 Spring Boot Admin报错。

2022-01-25 15:47:40.025  WARN 12808 --- [gistrationTask1] d.c.b.a.c.r.ApplicationRegistrator       : Failed to register application as Application(name=spring-boot-application, managementUrl=http://192.168.1.1:8080/actuator, healthUrl=http://192.168.1.1:8080/actuator/health, serviceUrl=http://192.168.1.1:8080/) at spring-boot-admin ([http://localhost:8081/instances]): I/O error on POST request for "http://localhost:8081/instances": Connect to localhost:8081 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect; nested exception is org.apache.http.conn.HttpHostConnectException: Connect to localhost:8081 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect. Further attempts are logged on DEBUG level

2022-01-25 15:47:40.025 WARN 12808 — [gistrationTask1] d.c.b.a.c.r.ApplicationRegistrator : Failed to register application as Application(name=spring-boot-application, managementUrl=http://192.168.1.1:8080/actuator, healthUrl=http://192.168.1.1:8080/actuator/health, serviceUrl=http://192.168.1.1:8080/) at spring-boot-admin ([http://localhost:8081/instances]): I/O error on POST request for “http://localhost:8081/instances”: Connect to localhost:8081 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect; nested exception is org.apache.http.conn.HttpHostConnectException: Connect to localhost:8081 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect. Further attempts are logged on DEBUG level

我的actuator用的8080端口,http://localhost:8080/actuator
admin的配置项用的8081

spring.boot.admin.client.url=http://localhost:8081

这个配置项的官方说明是:

通过配置 Spring Boot Admin Server 的 URL 来启用 SBA Client:(SBA是Spring Boot Admin)
要注册的 Spring Boot 管理服务器的 URL

我的理解是这个admin server的url就是actuator的url,
所以,把actuator的url放到这里就OK了。

spring.boot.admin.client.url=http://localhost:8080

另外,如果client端的url如果不想用主机名(http://rye-honor:8080/applications)。
那就加一下这个配置。

spring.boot.admin.client.instance.service-host-type=ip

如果你的admin依赖导入的版本比较老,找不到上面这个配置项,
就找一下有没有这个配置项。

spring.boot.admin.client.instance.prefer-ip=true

把这个设置为true就可以了。

进入源码可以看到。
/**
* Should the registered urls be built with server.address or with hostname.
* @deprecated Use serviceHostType instead.
*/
@Deprecated
private boolean preferIp = false;

新版本用“serviceHostType”替代。
但是这个配置在最新版本不会影响启动。所以配不配置都可以。

另外,记得配置这个。

management.endpoints.web.exposure.include=*

项目启动成功之后浏览器访问localhost:8080就可以了。

在这里插入图片描述

在这里插入图片描述

  • 6
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值