首页  

springboot2微服务实例     所属分类 spring 浏览量 1200
springboot版本 2.0.9.RELEASE
springcloud版本 Finchley.RELEASE


/Users/dugang/fun/hellocode/demo/springcloud

actuator	consumer	eureka		pom.xml		provider

启动 eureka 注册中心
cd eureka
mvn spring-boot:run

使用 spring-boot maven 插件 在 父 pom.xml里配置 插件



<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
</plugin>



http://127.0.0.1:9030/
http://127.0.0.1:9030/eureka/apps
默认返回 xml格式

curl -H 'Accept:application/json' http://127.0.0.1:9030/eureka/apps
返回json格式

http://127.0.0.1:9030/eureka/apps/provider




启动 服务提供者1 端口 9031
cd provider
mvn spring-boot:run

http://127.0.0.1:9031/serverInfo

启动 服务提供者2 端口 9041

mvn spring-boot:run -Dserver.port=9041

http://127.0.0.1:9041/serverInfo

启动 消费者 
cd consumer
mvn spring-boot:run

http://127.0.0.1:9032/status

http://127.0.0.1:9032/serverInfo


所有代码
https://gitee.com/dyyx/hellocode/tree/master/demo/springcloud



碰到的问题 
RestTemplate 忘记加 @LoadBalanced 注解 ,consumer请求报错
I/O error on GET request for "http://provider/serverInfo": provider; nested exception is java.net.UnknownHostException: provider

eureka注册中心只能看到 provider

上一篇     下一篇
springboot web端口设置三种方式

springboot2 actuator 使用

springboot2获取web端口

springcloud DiscoveryClient使用说明

maven知识点整理

springboot打包成可执行jar