主要分为以下几步:
(1)搭建SpringBootService,这里是各个微服务的业务逻辑。(这里搭建了2个Service,用来测试熔断)
(2)搭建SpringBootEureka,用来发现服务。
(3)搭建SpringBootConfig,用于动态维护配置文件。
(4)搭建SpringBootConsumer,这个不是必须的,只有当一个更大的业务需要调用其他多个微服务Service时才需要搭建。
可以通过Ribbon+RestTemplate,Feign两种方式进行微服务之间的调用。可以加入Hystrix进行熔断处理。
(5)搭建SpringBootZuul,用于路由控制。可以加入Hystrix用于熔断处理。
(6)使用Jenkins进行代码的自动化部署。
修改
读取本地config配置文件:
Git:git;
SVN:svn;
本地:native;
springbootconfig下配置文件application.yml
server:
port: 6002
spring:
application:
name: springbootConfig
profiles:
active: native
cloud:
config:
server:
native:
searchLocations: I:/study/SpringCloud-master/config
# active: subversion
# cloud:
# config:
# server:
# svn:
# uri: http://172.16.11.15/svn/concom/PRIVATE_CLOUD/PRIVATE_BACK_RESOLVER/GitHubProSC
## uri: git@github.com:kongfanjun10/spring-cloud-config.git
# username: kongfanjun
# password: Kongfanjun@1115
# default-label:
eureka:
client:
service-url:
defaultZone: http://localhost:5000/eureka/
instance:
preferIpAddress: true
instance-id: ${spring.cloud.client.ipAddress}:${server.port}
lease-expiration-duration-in-seconds: 30
lease-renewal-interval-in-seconds: 30