there are two spring cloud java project in serve dir which offer same restful api:
you can use those to mock below situation
p.s. the SpringCloud Server name is
pixiu-springcloud-server
, setting with application.yml
first, start Zookeeper use for Register Center, maybe you can use docker-compose
services: zookeeper: image: zookeeper ports: - "2181:2181"
second, start the SpringCloud Server, use start.sh or run with IDEA
mvn spring-boot:run
finally, check Server
curl http://localhost:9127/hi
result
Hello Pixiu World! from org.springframework.cloud.zookeeper.serviceregistry.ServiceInstanceRegistration@63a45760
or
find service instance info on zookeeper:
curl http://localhost:9127/service/pixiu-springcloud-server
result
[ { "serviceId": "pixiu-springcloud-server", "host": "127.0.0.1", "port": 9127, "secure": false, "uri": "http://127.0.0.1:9127", "metadata": { "instance_status": "UP" }, "serviceInstance": { "name": "pixiu-springcloud-server", "id": "1a7b120a-e77a-4a8d-ad3b-ca75473288a4", "address": "127.0.0.1", "port": 9127, "sslPort": null, "payload": { "@class": "org.springframework.cloud.zookeeper.discovery.ZookeeperInstance", "id": "pixiu-springcloud-server", "name": "pixiu-springcloud-server", "metadata": { "instance_status": "UP" } }, "registrationTimeUTC": 1640852269145, "serviceType": "DYNAMIC", "uriSpec": { "parts": [ { "value": "scheme", "variable": true }, { "value": "://", "variable": false }, { "value": "address", "variable": true }, { "value": ":", "variable": false }, { "value": "port", "variable": true } ] }, "enabled": true }, "instanceId": "1a7b120a-e77a-4a8d-ad3b-ca75473288a4", "scheme": null } ]
start Pixiu
gateway start -c samples/springcloud/pixiu/conf.yaml
practice proxy SpringCloud service base on Pixiu
curl http://127.0.0.1:8888/pixiu-springcloud-server/hi