一.操作步驟
- 客戶端依賴
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
- 客戶端配置文件
server:
port: 8081
spring:
application:
name: qyeurekaclient
profiles:
active: gr
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
- 啓動類
@Slf4j
@SpringBootApplication
@EnableDiscoveryClient
public class EurekaClientApplication
{
public static void main( String[] args )
{
ApplicationContext context = SpringApplication.run(EurekaClientApplication.class, args);
String serverPort = context.getEnvironment().getProperty("server.port");
log.info("後臺管理服務客戶端啓動成功! Url: http://127.0.0.1:".concat(serverPort));
}
}
- 界面展示
經由上面幾個步驟可以很輕鬆的集成客戶端。
項目地址:微服務集成項目