Spring Cloud服务注册【Eureka】
创建Eureka项目
结构如下图所示
需要修改的地方
启动控制台页面显示
浏览器访问http://localhost:8761
微服务项目整合Eureka
启动类启用Eureka
@SpringBootApplication(scanBasePackages = {"com.example.demo"})
@MapperScan("com.example.demo.*") //扫描的mapper
@EnableEurekaClient
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
pom文件引入Eureka配置信息
eureka: instance: hostname: localhost client: register-with-eureka: true fetch-registry: true service-url: defaultZone: http://localhost:8761/eureka/
pom添加相关依赖
org.springframework.cloud spring-cloud-starter-netflix-eureka-client