SpringBoot Eureka启动服务的端口和配置的端口不一致

spring:
    application:
        name: eureka-server

server:
    port: 8761 #启动端口

eureka:
    instance:
        hostname: eureka-server
        instance-id: ${spring.cloud.client.ipAddress}:${server.port}
        prefer-ip-address: true
    client:
        registerWithEureka: false  #false:不作为一个客户端注册到注册中心
        fetchRegistry: false      #为true时,可以启动,但报异常:Cannot execute request on any known server
        service-url:
          defaultZone: http://${EUREKA_HOST:localhost}:${server.port}/eureka/
    server:
        enable-self-preservation: false #关闭保护机制,确保注册中心可以将不可用的实例正确剔除
        eviction-interval-timer-in-ms: 3000
        response-cache-update-interval-ms: 2000

Eureka配置的端口是8761,一直启动正常,突然启动不正常了,启动端口口变成8780,导致其他服务注册Eureka失败

 原因:IDEA没有编译yml文件,解决办法:对Eureka项目重新install即可

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
# fat FAT ,基于springboot , 使用zookeeper,redis , spring async , spring transactionManager的强一致性分布式事务解决方案 ## 框架介绍 纯编码方式,强一致性。<br> 使用redis/zookeeper作为注册中心 ,代理事务的执行,使用spring async异步处理事务线程。<br> 基于注解使用,对业务代码可以说是零入侵,目前内置适配spring-cloud(Feign调用) , dubbo。<br> 同时具备一定的扩展性与兼容性,因为存在自定义的服务框架,或者以后会涌现出更多的流行分布式服务框架,所以会提供一些组件适配自定义服务框架。 ## Maven依赖 ```java <dependency> <groupId>com.github.cjyican</groupId> <artifactId>fat-common</artifactId> <version>1.0.6-RELEASE</version> </dependency> ``` ## 使用示例 ### step0:SpringBootApplication加上@EnableFat注解 ```java @SpringBootApplication @EnableEurekaClient @EnableDiscoveryClient @EnableFeignClients @EnableFat public class FatboyEurekaRibbonApplication { public static void main(String[] args) { SpringApplication.run(FatboyEurekaRibbonApplication.class, args); } } ``` ### step1:配置注册中心 使用redis/zookeeper作为注册中心,优先使用zookeeper。为隔离业务使用的redis和注册中心的redis,提供了一套属性配置。 在业务redis/zookeeper作为注册中心与注册中心相同时,也需要配置。 请保证各个服务的注册中心配置一致,否则无法协调分布式事务。 ```java #Fat # Redis数据库索引(默认为0) fat.redis.database=0 # Redis服务器地址 fat.redis.host= # Redis服务器连接端口 fat.redis.port=6379 # Redis服务器连接密码(默认为空) fat.redis.password= # 连接池最大连接数(使用负值表示没有限制) fat.redis.pool.max-active=20 # 连接池最大阻塞等待时间(使用负值表示没有限制) fat.redis.pool.max-wait=-1 # 连接池中的最大空闲连接 fat.redis.pool.max-idle=10 # 连接池中的最小空闲连接 fat.redis.pool.min-idle=2 # 连接超时时间(毫秒) fat.redis.timeout=1000 # 集群模式,如有配置,将优先使用集群 fat.redis.cluster.nodes=x.x.x.x:x,x.x.x.x:x # zookeeper服务器地址 fat.zookeeper.host=x.x.x.x:x,x.x.x.x:x # zookeeper活跃时间 fat.zookeeper.sessionTimeout=x.x.x.x:x,x.x.x.x:x ``` 应用标识,与spirng.application.name一致,必须配置 ```java spring.application.name=fatboy-eureka-ribbon ``` ### step2:服务入口方法加入注解@FatServiceRegister注册 在需要开启分布式事务管理的入口方法中加入注解@FatServiceRegister,注意不要重复添加。dubbo的直接加在serviceImpl.method上面就可以 ## 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。
启动Eureka服务,您需要按照以下步骤进行操作: 1. 首先,确保您已经安装了Java开发环境(JDK)并正确配置JAVA_HOME环境变量。 2. 在您的项目中添加Eureka依赖项。如果您正在使用Maven进行构建,可以在pom.xml文件中添加以下依赖项: ```xml <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> </dependency> ``` 3. 创建一个启动类,并使用`@EnableEurekaServer`注解将其标记为Eureka服务器。例如: ```java import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; @SpringBootApplication @EnableEurekaServer public class EurekaServerApplication { public static void main(String[] args) { SpringApplication.run(EurekaServerApplication.class, args); } } ``` 4. 在配置文件(application.properties或application.yml)中配置Eureka服务器的相关属性。例如: ```yaml server.port=8761 eureka.client.register-with-eureka=false eureka.client.fetch-registry=false ``` 上述配置Eureka服务器监听8761端口,并设置为不向其他Eureka服务器注册自身。 5. 运行启动类,Eureka服务器将会在端口8761上启动,并且您可以通过访问http://localhost:8761来访问Eureka的管理界面。 请注意,以上步骤是基于Spring Cloud Netflix提供的Eureka实现。如果您使用的是其他框架或工具,请参考其相应的文档进行配置启动

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值