pom 文件配置
<!--SprinCloud整合EurekaClient-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
yml配置
#配置会员服务端口号
server:
port: 8000
#服务别名
spring:
application:
name: app-member
eureka:
client:
#注册中心地址
service-url:
defaultZone: http://localhost:8100/eureka
#是否需要添加到注册中心
register-with-eureka: true
#是否需要检索配置中心信息
fetch-registry: true
启动类添加@EnableEurekaClient
@SpringBootApplication
//将服务注册到注册中心
@EnableEurekaClient
public class SpringcloudMamberApplication {
public static void main(String[] args) {
SpringApplication.run(SpringcloudMamberApplication.class, args);
}
}
创建MemberService.class
@RestController
public class MemberService {
@RequestMapping("/getMember")
public String getMember(){
return "我是会员服务";
}
}
网友评论