springcloud-Finchley.SR1

主依赖

com.lh
mypinyougou
1.0-SNAPSHOT
jar

mypinyougou
Demo project for Spring Boot


    manager-ui
    manager-server
    pinyougou-common
    eureka-server


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



    UTF-8
    UTF-8
    1.8



    
        org.springframework.cloud
        spring-cloud-starter
    
    
        org.springframework.boot
        spring-boot-starter
    

    
        org.springframework.boot
        spring-boot-starter-test
        test
    



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



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

eureka-server依赖

com.lh
eureka-server
0.0.1-SNAPSHOT
jar

eureka-server
Demo project for Spring Boot

    com.lh
    mypinyougou
    1.0-SNAPSHOT


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

eureka-server application.yml

spring:
  application:
    name: manager-server #服务名称
server:
  port: 9002 #启动端口号
eureka:
  client:
    register-with-eureka: true #是否注册到eureka服务器
    fetch-registry: true #是否可检索
    service-url:
      defaultZone: http://127.0.0.1:9001/eureka/ #服务中心

eureka-server代码

@SpringBootApplication
@EnableEurekaServer
public class EurekaServerApplication {
  public static void main(String[] args) {
    SpringApplication.run(EurekaServerApplication.class, args);
  }
}

manager-ui依赖

    com.lh
manager-ui
0.0.1-SNAPSHOT
jar

manager-ui
Demo project for Spring Boot

    com.lh
    mypinyougou
    1.0-SNAPSHOT


    
        org.springframework.boot
        spring-boot-starter-web
    
    
        org.springframework.cloud
        spring-cloud-starter-netflix-eureka-client
    
    
        org.springframework.cloud
        spring-cloud-starter-openfeign
    
    
        com.pinyougou
        pinyougou-common
        0.0.1-SNAPSHOT
    

manager-ui的application.yml

spring:
  application:
    name: manager-ui #服务名称
server:
  port: 9003 #启动端口号
eureka:
  client:
    register-with-eureka: true #是否注册到eureka服务器
    fetch-registry: true #是否可检索
    service-url:
      defaultZone: http://127.0.0.1:9001/eureka/ #服务中心

manager-ui的启动方法

@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients // 调用服务提供方时启用负载均衡
public class ManagerUiApplication {
    public static void main(String[] args) {
    SpringApplication.run(ManagerUiApplication.class, args);
  }
}

注意 :This will cause @Autowired to not work because there isn’t exactly one bean, or one marked as primary. To work around this, Spring Cloud Netflix marks all Feign instances as @Primary如下:

 @FeignClient(name = "manager-server", primary = false)

其他资源参考:
springcloud
https://blog.csdn.net/qq_42606051/article/details/81776303

你可能感兴趣的:(springcloud-Finchley.SR1)