xuanbg
V2EX  ›  Java

请教一个奇怪的问题,关于 Spring cloud 的一个配置

  •  
  •   xuanbg ·
    xuanbg · Jun 8, 2023 · 3565 views
    This topic created in 1245 days ago, the information mentioned may be changed or developed.

    我的项目用的是 Spring boot 3.0.6 + Spring cloud 2022.0.1 ,配置中心是 Consul1.14.1 。

    然后,就有个非常奇怪的问题,spring.cloud.inetutils.preferred-networks 这个配置项我怎么配都不管用。服务总是用 WIFI 的 IP 192.168.16.100 注册,而不是我配置的 VPN 分配到的地址 192.168.18.100 。

    有没有大神能给给指点一下

    6 replies  •  2023-06-08 11:32:24 +08:00
    mannixSuo
    mannixSuo
    Jun 8, 2023
    1
    你的 vpn 又不是网卡,spring.cloud.inetutils.preferred-networks 查找的是网卡对应的地址
    lauke
    lauke
    Jun 8, 2023
    2
    把不用的网卡忽略掉,举个例子,这个是忽略 vm 虚拟机的网卡-Dspring.cloud.inetutils.ignoredInterfaces=VMware.*
    lauke
    lauke
    Jun 8, 2023
    3
    -Dspring.cloud.inetutils.ignoredInterfaces=VMware.*
    ixx
    ixx
    Jun 8, 2023
    4
    试试 spring.cloud.consul.discovery.ipAddress
    使用的时候记得指定 spring.cloud.consul.discovery.preferIpAddress=true
    xuanbg
    xuanbg
    OP
    Jun 8, 2023
    5
    以上,感谢各位回复。但无论是忽略网卡还是指点 ip ,都没用😂😂😂
    xuanbg
    xuanbg
    OP
    Jun 8, 2023
    6
    这个参数我以前也用过,那时 Spring boot 版本应该是 2.7.5 ,是可以的通过正则来匹配你想要的 ip 的。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1698 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 23:40 · PVG 07:40 · LAX 15:40 · JFK 18:40
    ♥ Do have faith in what you're doing.