在APP启动后,tomcat的端口号确实是配置的端口,可是注册到eureka中的端口却变成了8080(默认配置端口),这个时候需要对eureka客户端配置注册端口号,如下:

增加eureka.instance.nonSecurePort,配置为当前服务器的端口号即可解决问题

spring:
  application:
    name: sns-cloud-demo-service
  cloud:
    config:
      discovery:
        enabled: false
        serviceId: config-center
eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:8761/eureka/  #注册中心地址
    registerWithEureka: true
    fetchRegistry: true
  instance:
    hostname: ${spring.cloud.client.ipAddress}
    instance-id: ${spring.cloud.client.ipAddress}:${server.port}
    prefer-ip-address: true
    nonSecurePort: ${server.port}
server:
  port: 8081


Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐