一、配置Eureka-Server,作为服务的注册中心
1、新建一个maven工程,在pom文件中引入相关依赖
<dependency> <groupId>org.springframework.cloud</groupId> <!-- 注意这里是netflix-eureka-server,表明是服务端 --> <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> </dependency>
2、在application.yml(application.properties)中进行配置
#设置eureka-server端口 server: port: 8761 eureka: instance: #主机名,要在hosts文件中进行配置 hostname: eureka-server-8761 client: #是否注册到eureka register-with-eureka: false #是否从eureka中获取服务信息 fetch-registry: false #设置服务注册中心地址 service-url: defaultZone: http://eureka8761.com:8761/eureka/
3、在主启动类使用@EnableEurekaServer,表明这里是服务端
@EnableEurekaServer @SpringBootApplication public class EurekaServerApplication_8761 { public static void main(String[] args) { SpringApplication.run(EurekaServerApplication_8