php开发微服务注册到eureka中(使用sidecar)

使用php开发微服务,注册到eureka中的解决方案:sidecar。

sidecar 介绍请见:https://blog.csdn.net/qq_32971807/article/details/53742783

 

 

  POM文件

  

com.ylm
	side_car_test
	0.0.1-SNAPSHOT
	jar
	side_car_test
	


	
		org.springframework.boot
		spring-boot-starter-parent
		2.0.4.RELEASE
		 
	

	
		UTF-8
		UTF-8
		1.8
	

	
	
		
			aliRepository
			aliRepository
			http://maven.aliyun.com/nexus/content/groups/public/
			
				false
			
		
	

	
	
		
			
				org.springframework.cloud
				spring-cloud-dependencies
				Finchley.RELEASE
				pom
				import
			
		
	

	
		
			org.springframework.boot
			spring-boot-starter
		

		
			org.springframework.boot
			spring-boot-starter-test
			test
		
		
			org.springframework.cloud
			spring-cloud-netflix-sidecar
		

		
			org.springframework.cloud
			spring-cloud-starter-netflix-eureka-client
		
	

	
		
			
				org.springframework.boot
				spring-boot-maven-plugin
			
		
	

  启动类 

@SpringBootApplication
@EnableSidecar
public class SideCarServerApplication {

	public static void main(String[] args) {
		SpringApplication.run(SideCarServerApplication.class, args);
	}
}

  YLM

eureka:
  instance:
    hostname: localhost

  client:
    register-with-eureka: true
    fetch-registry: true
    serviceUrl:
      defaultZone: http://eureka.tz.ylmo2o.com:20881/eureka/

sidecar:
  port: 80
  instance:
    hostname: localhost
  health-uri: http://${sidecar.instance.hostname}:${sidecar.port}/health.php

反馈php服务是否健康的代码

   php rest接口

  

'啊啊');
echo json_encode($arr,JSON_UNESCAPED_UNICODE);

     java 服务消费者 接口

@FeignClient(value = "testPhp", configuration=FeignConfiguration.class)
public interface SideCarApiService {
    @RequestLine("POST /hello.php")
    HashMap sayHello();
}

    重头戏 PHP 调用注册中心的其他服务的接口

   

 

你可能感兴趣的:(php开发微服务注册到eureka中(使用sidecar))