关于我们

质量为本、客户为根、勇于拼搏、务实创新

< 返回新闻公共列表

搭建Eureka注册中心

发布时间:2023-07-01 00:28:23
先创建一个maven项目 导入springboot springcloud和Eureka相关依赖 依赖这里一直有错误,改了半天才可以用 ,用的是磊宇云的仓库下载的。 4.0.0 com.vhukze.Eureka Eureka 0.0.1-SNAPSHOT war Eureka org.springframework.boot spring-boot-parent 2.0.3.RELEASE org.springframework.cloud spring-cloud-dependencies Finchley.M7 pom import org.springframework.cloud spring-cloud-starter-netflix-eureka-server spring-milestones Spring Milestones https://repo.spring.io/milestone false repository.springframework.maven.release Spring Framework Maven Release Repository http://maven.springframework.org/milestone/ org.springframework http://maven.springframework.org/snapshot spring-milestone Spring Maven MILESTONE Repository http://repo.spring.io/libs-milestone spring-release Spring Maven RELEASE Repository http://repo.spring.io/libs-release org.springframework.boot spring-boot-maven-plugin resources下的application.yml 文件 #服务端口号 server: port: 8100 eureka: instance: #注册中心ip hostname: 127.0.0.1 client: serviceUrl: #注册地址 defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/ #是否需要把吧本项目注册到注册中心 register-with-eureka: false #因为自己是注册中心 所以不需要检索服务 fetch-registry: false 然后写一个启动类 package com.vhukze.app; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; /** * @author zsz * @version * @创建时间:2019年10月9日 上午8:52:42 */ @SpringBootApplication(exclude= {DataSourceAutoConfiguration.class}) @EnableEurekaServer public class EurekaApp { //@EnableEurekaServer表示开启服务 开启注册中心 public static void main(String[] args) { SpringApplication.run(EurekaApp.class, args); } } 启动项目访问localhost:8100现在是还没有提供者 所以这里是空的

/template/Home/leiyu/PC/Static