在idea中

还是老套路,加注解

高版本的需要加
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
配置文件application,yml
spring:
application:
name: client
eureka:
client:
service-url:
defaultzone: http://localhost:8761/eureka/
instance:
hostname: clientname
访问http://localhost:8761

另外我测试的@EnableDiscoveryClient与@EnableEurekaClient,这2个注解都是可以的,如有问题,可用指出。
回到Eureka Server注册中心项目中,在application.yml加上eureka.server.enable-self-preservation:false配置,
注意只能在开发环境把它关闭,生成环境不要关闭了一定要打开,方便做微服务的调用,不会出现错误

本文介绍在IDEA中配置Spring Boot微服务的过程,包括添加依赖、配置application.yml及使用@EnableDiscoveryClient或@EnableEurekaClient注解。同时,文中提及了在EurekaServer注册中心配置eureka.server.enable-self-preservation的注意事项。
246

被折叠的 条评论
为什么被折叠?



