springcloud实战篇四之Eureka-client(服务提供者)集群创建

下面搭建一个Eureka-client的服务提供者集群

springcloud实战篇四之Eureka-client(服务提供者)集群创建_第1张图片

1.三个工程的pom.xml依赖是一样的,所以就仅贴出一个


  4.0.0
  
    com.yxf.springcloud
    mymicroservicecloud
    0.0.1-SNAPSHOT
  
  mymicroservicecloud-provider-dept-8001
  
		
		
			com.yxf.springcloud
			mymicroservicecloud-api
			${project.version}
		
		
		
			org.springframework.boot
			spring-boot-starter-actuator
		
		
		
			org.springframework.cloud
			spring-cloud-starter-eureka
		
		
			org.springframework.cloud
			spring-cloud-starter-config
		
		
			junit
			junit
		
		
			mysql
			mysql-connector-java
		
		
			com.alibaba
			druid
		
		
			ch.qos.logback
			logback-core
		
		
			org.mybatis.spring.boot
			mybatis-spring-boot-starter
		
		
			org.springframework.boot
			spring-boot-starter-jetty
		
		
			org.springframework.boot
			spring-boot-starter-web
		
		
			org.springframework.boot
			spring-boot-starter-test
		
		
		
			org.springframework
			springloaded
		
		
			org.springframework.boot
			spring-boot-devtools
		
	
  

2.三个工程的application.yml文件

server:
  port: 8001
  
mybatis:
  config-location: classpath:mybatis/mybatis.cfg.xml        # mybatis配置文件所在路径
  type-aliases-package: com.yxf.springcloud.entities    # 所有Entity别名类所在包
  mapper-locations:
  - classpath:mybatis/mapper/**/*.xml                       # mapper映射文件
    
spring:
   application:
    name: MICROSERVICECLOUD-DEPT                        #对外暴露的服务(微服务)
   datasource:
    type: com.alibaba.druid.pool.DruidDataSource            # 当前数据源操作类型
    driver-class-name: org.gjt.mm.mysql.Driver              # mysql驱动包
    url: jdbc:mysql://localhost:3306/clouddb1              # 数据库名称
    username: root
    password: 123456
    dbcp2:
      min-idle: 5                                           # 数据库连接池的最小维持连接数
      initial-size: 5                                       # 初始化连接数
      max-total: 5                                          # 最大连接数
      max-wait-millis: 200                                  # 等待连接获取的最大超时时间
      
eureka:
  client: #客户端注册进eureka服务列表内
    service-url: 
      #defaultZone: http://localhost:1001/eureka
      defaultZone: http://eureka1001.com:1001/eureka/,http://eureka1002.com:1002/eureka/,http://eureka1003.com:1003/eureka/      
  instance:
    instance-id: microservicecloud-dept8001    
    prefer-ip-address: true     # 访问路径可以显示IP地址     
 
info: 
  app.name: yxf-mymicroservicecloud
  company.name: www.yxf.com
  build.artifactId: $project.artifactId$
  build.version: $project.version$


---------------------------------------


server:
  port: 8002
  
mybatis:
  config-location: classpath:mybatis/mybatis.cfg.xml        # mybatis配置文件所在路径
  type-aliases-package: com.yxf.springcloud.entities    # 所有Entity别名类所在包
  mapper-locations:
  - classpath:mybatis/mapper/**/*.xml                       # mapper映射文件
    
spring:
   application:
    name: MICROSERVICECLOUD-DEPT                        #对外暴露的服务(微服务)
   datasource:
    type: com.alibaba.druid.pool.DruidDataSource            # 当前数据源操作类型
    driver-class-name: org.gjt.mm.mysql.Driver              # mysql驱动包
    url: jdbc:mysql://localhost:3306/clouddb2             # 数据库名称
    username: root
    password: 123456
    dbcp2:
      min-idle: 5                                           # 数据库连接池的最小维持连接数
      initial-size: 5                                       # 初始化连接数
      max-total: 5                                          # 最大连接数
      max-wait-millis: 200                                  # 等待连接获取的最大超时时间
      
eureka:
  client: #客户端注册进eureka服务列表内
    service-url: 
      #defaultZone: http://localhost:1001/eureka
      defaultZone: http://eureka1001.com:1001/eureka/,http://eureka1002.com:1002/eureka/,http://eureka1003.com:1003/eureka/      
  instance:
    instance-id: MICROSERVICECLOUD-DEPT2    
    prefer-ip-address: true     # 访问路径可以显示IP地址     
 
info: 
  app.name: yxf-mymicroservicecloud
  company.name: www.yxf.com
  build.artifactId: $project.artifactId$
  build.version: $project.version$

---------------------------------

server:
  port: 8003
  
mybatis:
  config-location: classpath:mybatis/mybatis.cfg.xml        # mybatis配置文件所在路径
  type-aliases-package: com.yxf.springcloud.entities    # 所有Entity别名类所在包
  mapper-locations:
  - classpath:mybatis/mapper/**/*.xml                       # mapper映射文件
    
spring:
   application:
    name: MICROSERVICECLOUD-DEPT                        #对外暴露的服务(微服务)
   datasource:
    type: com.alibaba.druid.pool.DruidDataSource            # 当前数据源操作类型
    driver-class-name: org.gjt.mm.mysql.Driver              # mysql驱动包
    url: jdbc:mysql://localhost:3306/clouddb3              # 数据库名称
    username: root
    password: 123456
    dbcp2:
      min-idle: 5                                           # 数据库连接池的最小维持连接数
      initial-size: 5                                       # 初始化连接数
      max-total: 5                                          # 最大连接数
      max-wait-millis: 200                                  # 等待连接获取的最大超时时间
      
eureka:
  client: #客户端注册进eureka服务列表内
    service-url: 
      #defaultZone: http://localhost:1001/eureka
      defaultZone: http://eureka1001.com:1001/eureka/,http://eureka1002.com:1002/eureka/,http://eureka1003.com:1003/eureka/      
  instance:
    instance-id: MICROSERVICECLOUD-DEPT3    
    prefer-ip-address: true     # 访问路径可以显示IP地址     
 
info: 
  app.name: yxf-mymicroservicecloud
  company.name: www.yxf.com
  build.artifactId: $project.artifactId$
  build.version: $project.version$

大家可以通过yml文件查看三个工程的区别,由于yml文件已经做了很详细到注释,现在就不重复了

效果演示

springcloud实战篇四之Eureka-client(服务提供者)集群创建_第2张图片


你可能感兴趣的:(springcloud实战篇,springcloud,Eureka,java,yangxf专栏,springcloud实战篇,springcloud,Eureka,java)