zoukankan      html  css  js  c++  java
  • Hystrix集群及集群监控turbine

    Hystrix集群及监控turbine

    前面Dashboard演示的仅仅是单机服务监控,实际项目基本都是集群,所以这里集群监控用的是turbine。

    turbine是基于Dashboard的。

    先搞个集群;

    microservice-student-provider-hystrix-1004项目的基础上再搞一个microservice-student-provider-hystrix-1005

     

    代码和配置都复制一份,然后修改几个地方;

    1、yml配置 

      1 ---
      2 server:
      3   port: 1004
      4   context-path: /
      5 spring:
      6   datasource:
      7     type: com.alibaba.druid.pool.DruidDataSource
      8     driver-class-name: com.mysql.jdbc.Driver
      9     url: jdbc:mysql://localhost:3306/j2ee?useUnicode=true&characterEncoding=utf8
     10     username: root
     11     password: 12345
     12   jpa:
     13     hibernate:
     14       ddl-auto: update
     15     show-sql: true
     16   application:
     17     name: microservice-student
     18   profiles: provider-hystrix-1004
     19 
     20 eureka:
     21   instance:
     22     hostname: localhost
     23     appname: microservice-student
     24     instance-id: microservice-student:1004
     25     prefer-ip-address: true
     26   client:
     27     service-url:
     28       defaultZone: http://eureka2001.yuan.com:2001/eureka/,http://eureka2002.yuan.com:2002/eureka/,http://eureka2003.yuan.com:2003/eureka/
     29 
     30 info:
     31   groupId: com.yuan.testSpringcloud
     32   artifactId: microservice-student-provider-hystrix-1004
     33   version: 1.0-SNAPSHOT
     34   userName: http://yuan.com
     35   phone: 123456
     36 
     37 hystrix:
     38   command:
     39     default:
     40       execution:
     41         isolation:
     42           thread:
     43             timeoutInMilliseconds: 1500
     44 
     45 ---
     46 server:
     47   port: 1005
     48   context-path: /
     49 spring:
     50   datasource:
     51     type: com.alibaba.druid.pool.DruidDataSource
     52     driver-class-name: com.mysql.jdbc.Driver
     53     url: jdbc:mysql://localhost:3306/j2ee?useUnicode=true&characterEncoding=utf8
     54     username: root
     55     password: 12345
     56   jpa:
     57     hibernate:
     58       ddl-auto: update
     59     show-sql: true
     60   application:
     61     name: microservice-student
     62   profiles: provider-hystrix-1005
     63 
     64 eureka:
     65   instance:
     66     hostname: localhost
     67     appname: microservice-student
     68     instance-id: microservice-student:1005
     69     prefer-ip-address: true
     70   client:
     71     service-url:
     72       defaultZone: http://eureka2001.yuan.com:2001/eureka/,http://eureka2002.yuan.com:2002/eureka/,http://eureka2003.yuan.com:2003/eureka/
     73 
     74 info:
     75   groupId: com.yuan.testSpringcloud
     76   artifactId: microservice-student-provider-hystrix-1005
     77   version: 1.0-SNAPSHOT
     78   userName: http://yuan.com
     79   phone: 123456
     80 
     81 hystrix:
     82   command:
     83     default:
     84       execution:
     85         isolation:
     86           thread:
     87             timeoutInMilliseconds: 1500
     88 
     89 ---
     90 server:
     91   port: 1006
     92   context-path: /
     93 spring:
     94   datasource:
     95     type: com.alibaba.druid.pool.DruidDataSource
     96     driver-class-name: com.mysql.jdbc.Driver
     97     url: jdbc:mysql://localhost:3306/j2ee?useUnicode=true&characterEncoding=utf8
     98     username: root
     99     password: 12345
    100   jpa:
    101     hibernate:
    102       ddl-auto: update
    103     show-sql: true
    104   application:
    105     name: microservice-student
    106   profiles: provider-hystrix-1006
    107 
    108 eureka:
    109   instance:
    110     hostname: localhost
    111     appname: microservice-student
    112     instance-id: microservice-student:1006
    113     prefer-ip-address: true
    114   client:
    115     service-url:
    116       defaultZone: http://eureka2001.yuan.com:2001/eureka/,http://eureka2002.yuan.com:2002/eureka/,http://eureka2003.yuan.com:2003/eureka/
    117 
    118 info:
    119   groupId: com.yuan.testSpringcloud
    120   artifactId: microservice-student-provider-hystrix-1006
    121   version: 1.0-SNAPSHOT
    122   userName: http://yuan.com
    123   phone: 123456
    124 
    125 hystrix:
    126   command:
    127     default:
    128       execution:
    129         isolation:
    130           thread:
    131             timeoutInMilliseconds: 1500

    2、启动类配置

     

     1 package com.yuan.microservicestudentproviderhystrix;
     2 
     3 import org.springframework.boot.SpringApplication;
     4 import org.springframework.boot.autoconfigure.SpringBootApplication;
     5 import org.springframework.boot.autoconfigure.domain.EntityScan;
     6 import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
     7 import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
     8 
     9 @EnableCircuitBreaker
    10 @EntityScan("com.yuan.*.*")
    11 @EnableEurekaClient
    12 @SpringBootApplication
    13 public class MicroserviceStudentProviderHystrixApplication {
    14 
    15     public static void main(String[] args) {
    16         SpringApplication.run(MicroserviceStudentProviderHystrixApplication.class, args);
    17     }
    18 
    19 }

     

     

    这样的话 就有了 hystrix集群服务;

     

    3、我们新建项目microservice-student-consumer-hystrix-turbine-91

    pom.xml加下依赖

     1 <?xml version="1.0" encoding="UTF-8"?>
     2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     3          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
     4     <modelVersion>4.0.0</modelVersion>
     5     <parent>
     6         <groupId>com.yuan</groupId>
     7         <artifactId>t226microservice</artifactId>
     8         <version>1.0-SNAPSHOT</version>
     9     </parent>
    10     <artifactId>microservice-student-consumer-hystrix-turbine-91</artifactId>
    11 
    12     <properties>
    13         <java.version>1.8</java.version>
    14     </properties>
    15 
    16     <dependencies>
    17         <dependency>
    18             <groupId>org.springframework.boot</groupId>
    19             <artifactId>spring-boot-starter</artifactId>
    20         </dependency>
    21 
    22         <dependency>
    23             <groupId>org.springframework.boot</groupId>
    24             <artifactId>spring-boot-starter-test</artifactId>
    25             <scope>test</scope>
    26             <exclusions>
    27                 <exclusion>
    28                     <groupId>org.junit.vintage</groupId>
    29                     <artifactId>junit-vintage-engine</artifactId>
    30                 </exclusion>
    31             </exclusions>
    32         </dependency>
    33 
    34         <dependency>
    35             <groupId>org.springframework.boot</groupId>
    36             <artifactId>spring-boot-starter-actuator</artifactId>
    37         </dependency>
    38         <dependency>
    39             <groupId>org.springframework.cloud</groupId>
    40             <artifactId>spring-cloud-starter-turbine</artifactId>
    41         </dependency>
    42 
    43     </dependencies>
    44 
    45     <build>
    46         <plugins>
    47             <plugin>
    48                 <groupId>org.springframework.boot</groupId>
    49                 <artifactId>spring-boot-maven-plugin</artifactId>
    50             </plugin>
    51         </plugins>
    52     </build>
    53 
    54 </project>

    添加application.yml的配置

     1 server:
     2   port: 91
     3   context-path: /
     4 eureka:
     5   client:
     6     service-url:
     7       defaultZone: http://eureka2001.yuan.com:2001/eureka/,http://eureka2002.yuan.com:2002/eureka/,http://eureka2003.yuan.com:2003/eureka/
     8 turbine:
     9   app-config: microservice-student   
    10   clusterNameExpression: "'default'" 
    11 spring:
    12   application:
    13     name: turbine

    1、启动类MicroserviceStudentConsumerHystrixTurbine91Application 加注解:@EnableTurbine

     1 package com.yuan.microservicestudentconsumerhystrixturbine91;
     2 
     3 import org.springframework.boot.SpringApplication;
     4 import org.springframework.boot.autoconfigure.SpringBootApplication;
     5 import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
     6 import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
     7 import org.springframework.cloud.netflix.turbine.EnableTurbine;
     8 
     9 @SpringBootApplication(exclude={DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class})
    10 @EnableTurbine
    11 public class MicroserviceStudentConsumerHystrixTurbine91Application {
    12 
    13     public static void main(String[] args) {
    14         SpringApplication.run(MicroserviceStudentConsumerHystrixTurbine91Application.class, args);
    15     }
    16 
    17 }

    测试:

    先启动三个eureka,然后把1004  1005 hystrix的服务都启动;

    microservice-student-consumer-80这个也启动,方便测试;

    dashboardturbine启动;

     

    这样的话 http://localhost/student/hystrix 就能调用服务集群;

    http://localhost:91/turbine.stream  可以监控数据,实时ping 返回data

     

     

    Feign、Hystrix整合

    前面的代码,用@HystrixCommand fallbackMethod是很不好的,因为和业务代码耦合度太高,不利于维护,所以需要解耦,这我们讲下Feign Hystrix整合。

     

    1、microservice-student-provider-hystrix项目修改

    我们不用原先那套。按照正常的逻辑来写;

    StudentService加新的接口方法:

     1 package com.yuan.microservicestudentproviderhystrix.service;
     2 
     3 import com.yuan.microservicecommon.entity.Student;
     4 
     5 import java.util.List;
     6 import java.util.Map;
     7 
     8 public interface StudentService {
     9  
    10     public void save(Student student);
    11      
    12     public Student findById(Integer id);
    13      
    14     public List<Student> list();
    15      
    16     public void delete(Integer id);
    17 
    18     /**
    19      * 测试Hystrix服务降级
    20      * @return
    21      */
    22     public Map<String,Object> hystrix();
    23      
    24      
    25 }

    实现类

     1 package com.yuan.microservicestudentproviderhystrix.service.impl;
     2 
     3 import com.yuan.microservicecommon.entity.Student;
     4 import com.yuan.microservicestudentproviderhystrix.repository.StudentRepository;
     5 import com.yuan.microservicestudentproviderhystrix.service.StudentService;
     6 import org.springframework.beans.factory.annotation.Autowired;
     7 import org.springframework.beans.factory.annotation.Value;
     8 import org.springframework.stereotype.Service;
     9 
    10 import java.util.HashMap;
    11 import java.util.List;
    12 import java.util.Map;
    13 
    14 @Service
    15 public class StudentServiceImpl implements StudentService {
    16     @Autowired
    17     private StudentRepository studentRepository;
    18 
    19     @Value("${server.port}")
    20     private String port;
    21 
    22     @Override
    23     public void save(Student student) {
    24         studentRepository.save(student);
    25     }
    26 
    27     @Override
    28     public Student findById(Integer id) {
    29         return studentRepository.findOne(id);
    30     }
    31 
    32     @Override
    33     public List<Student> list() {
    34         return studentRepository.findAll();
    35     }
    36 
    37     @Override
    38     public void delete(Integer id) {
    39         studentRepository.delete(id);
    40     }
    41 
    42     @Override
    43     public Map<String, Object> hystrix() {
    44         Map<String,Object> map=new HashMap<String,Object>();
    45         map.put("code", 200);
    46         map.put("info","工号【"+port+"】正在为您服务");
    47         return map;
    48     }
    49 
    50 }

    Controller层

     1 package com.yuan.microservicestudentproviderhystrix.controller;
     2 
     3 import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
     4 import com.yuan.microservicecommon.entity.Student;
     5 import com.yuan.microservicestudentproviderhystrix.service.StudentService;
     6 import org.springframework.beans.factory.annotation.Autowired;
     7 import org.springframework.beans.factory.annotation.Value;
     8 import org.springframework.web.bind.annotation.*;
     9 
    10 import java.util.HashMap;
    11 import java.util.List;
    12 import java.util.Map;
    13 
    14 @RestController
    15 @RequestMapping("/student")
    16 public class StudentProviderController {
    17  
    18     @Autowired
    19     private StudentService studentService;
    20 
    21     @Value("${server.port}")
    22     private String port;
    23      
    24     @PostMapping(value="/save")
    25     public boolean save(Student student){
    26         try{
    27             studentService.save(student);  
    28             return true;
    29         }catch(Exception e){
    30             return false;
    31         }
    32     }
    33      
    34     @GetMapping(value="/list")
    35     public List<Student> list(){
    36         return studentService.list();
    37     }
    38      
    39     @GetMapping(value="/get/{id}")
    40     public Student get(@PathVariable("id") Integer id){
    41         return studentService.findById(id);
    42     }
    43      
    44     @GetMapping(value="/delete/{id}")
    45     public boolean delete(@PathVariable("id") Integer id){
    46         try{
    47             studentService.delete(id);
    48             return true;
    49         }catch(Exception e){
    50             return false;
    51         }
    52     }
    53 
    54     @RequestMapping("/ribbon")
    55     public String ribbon(){
    56         return "工号【"+port+"】正在为您服务";
    57     }
    58 
    59     /**
    60      * 测试Hystrix服务降级
    61      * @return
    62      * @throws InterruptedException
    63      */
    64     @ResponseBody
    65     @GetMapping(value="/hystrix")
    66 //    @HystrixCommand(fallbackMethod="hystrixFallback")
    67     public Map<String,Object> hystrix() throws InterruptedException{
    68         Thread.sleep(1000);
    69 //        Map<String,Object> map=new HashMap<String,Object>();
    70 //        map.put("code", 200);
    71 //        map.put("info","工号【"+port+"】正在为您服务");
    72 //        return map;
    73         return this.studentService.hystrix();
    74     }
    75 
    76 //    public Map<String,Object> hystrixFallback() throws InterruptedException{
    77 //        Map<String,Object> map=new HashMap<String,Object>();
    78 //        map.put("code", 500);
    79 //        map.put("info", "系统【"+port+"】繁忙,稍后重试");
    80 //        return map;
    81 //    }
    82 
    83 }

    microservice-common项目修改StudentClientService

     1 package com.yuan.microservicecommon.service;
     2 
     3 import com.yuan.microservicecommon.entity.Student;
     4 import org.springframework.cloud.netflix.feign.FeignClient;
     5 import org.springframework.web.bind.annotation.GetMapping;
     6 import org.springframework.web.bind.annotation.PathVariable;
     7 import org.springframework.web.bind.annotation.PostMapping;
     8 import org.springframework.web.bind.annotation.RequestMapping;
     9 
    10 import java.util.List;
    11 import java.util.Map;
    12 
    13 /**
    14  * Student Feign接口客户端
    15  * @author Administrator
    16  *
    17  */
    18 @FeignClient(value="MICROSERVICE-STUDENT",fallbackFactory=StudentClientFallbackFactory.class)
    19 public interface StudentClientService {
    20  
    21     /**
    22      * 根据id查询学生信息
    23      * @param id
    24      * @return
    25      */
    26     @GetMapping(value="/student/get/{id}")
    27     public Student get(@PathVariable("id") Integer id);
    28      
    29     /**
    30      * 查询学生信息
    31      * @return
    32      */
    33     @GetMapping(value="/student/list")
    34     public List<Student> list();
    35      
    36     /**
    37      * 添加或者修改学生信息
    38      * @param student
    39      * @return
    40      */
    41     @PostMapping(value="/student/save")
    42     public boolean save(Student student);
    43      
    44     /**
    45      * 根据id删除学生信息
    46      * @return
    47      */
    48     @GetMapping(value="/student/delete/{id}")
    49     public boolean delete(@PathVariable("id") Integer id);
    50 
    51     @RequestMapping("/student/ribbon")
    52     public String ribbon();
    53 
    54     @RequestMapping("/student/hystrix")
    55     public Map<String,Object> hystrix();
    56 
    57 
    58 }

    StudentClientService接口的@FeignClient注解加下 fallbackFactory属性

    1 @FeignClient(value="MICROSERVICE-STUDENT",fallbackFactory=StudentClientFallbackFactory.class)

    2、microservice-common项目新建FallbackFactory类,解耦服务熔断服务降级

    StudentClientService接口,新增getInfo方法;

    1 /**
    2  * 服务熔断降级
    3  * @return
    4  */
    5 @GetMapping(value="/student/hystrix")
    6 public Map<String,Object> hystrix();

    新建 StudentClientFallbackFactory 类,实现FallbackFactory<StudentClientService>接口;

     1 package com.yuan.microservicecommon.service;
     2 
     3 import com.yuan.microservicecommon.entity.Student;
     4 import feign.hystrix.FallbackFactory;
     5 import org.springframework.stereotype.Component;
     6 
     7 import java.util.HashMap;
     8 import java.util.List;
     9 import java.util.Map;
    10 
    11 @Component
    12 public class StudentClientFallbackFactory implements FallbackFactory<StudentClientService> {
    13 
    14     @Override
    15     public StudentClientService create(Throwable throwable) {
    16         return new StudentClientService() {
    17             @Override
    18             public Student get(Integer id) {
    19                 return null;
    20             }
    21 
    22             @Override
    23             public List<Student> list() {
    24                 return null;
    25             }
    26 
    27             @Override
    28             public boolean save(Student student) {
    29                 return false;
    30             }
    31 
    32             @Override
    33             public boolean delete(Integer id) {
    34                 return false;
    35             }
    36 
    37             @Override
    38             public String ribbon() {
    39                 return null;
    40             }
    41 
    42             @Override
    43             public Map<String, Object> hystrix() {
    44                Map<String,Object> map=new HashMap<String,Object>();
    45                   map.put("code", 500);
    46                   map.put("info", "系统繁忙,稍后重试");
    47                return map;
    48             }
    49         };
    50 
    51     }
    52 }

    修改项目microservice-student-provider-hystrix-1004

    Controller层

     1 package com.yuan.microservicestudentproviderhystrix1004.controller;
     2 
     3 import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
     4 import com.yuan.microservicecommon.entity.Student;
     5 import com.yuan.microservicestudentproviderhystrix1004.service.StudentService;
     6 import org.springframework.beans.factory.annotation.Autowired;
     7 import org.springframework.beans.factory.annotation.Value;
     8 import org.springframework.web.bind.annotation.*;
     9 
    10 import java.util.HashMap;
    11 import java.util.List;
    12 import java.util.Map;
    13 
    14 @RestController
    15 @RequestMapping("/student")
    16 public class StudentProviderController {
    17  
    18     @Autowired
    19     private StudentService studentService;
    20 
    21     @Value("${server.port}")
    22     private String port;
    23      
    24     @PostMapping(value="/save")
    25     public boolean save(Student student){
    26         try{
    27             studentService.save(student);  
    28             return true;
    29         }catch(Exception e){
    30             return false;
    31         }
    32     }
    33      
    34     @GetMapping(value="/list")
    35     public List<Student> list(){
    36         return studentService.list();
    37     }
    38      
    39     @GetMapping(value="/get/{id}")
    40     public Student get(@PathVariable("id") Integer id){
    41         return studentService.findById(id);
    42     }
    43      
    44     @GetMapping(value="/delete/{id}")
    45     public boolean delete(@PathVariable("id") Integer id){
    46         try{
    47             studentService.delete(id);
    48             return true;
    49         }catch(Exception e){
    50             return false;
    51         }
    52     }
    53 
    54     @RequestMapping("/ribbon")
    55     public String ribbon(){
    56         return "工号【"+port+"】正在为您服务";
    57     }
    58 
    59     /**
    60      * 测试Hystrix服务降级
    61      * @return
    62      * @throws InterruptedException
    63      */
    64     @ResponseBody
    65     @GetMapping(value="/hystrix")
    66 //    @HystrixCommand(fallbackMethod="hystrixFallback")
    67     public Map<String,Object> hystrix() throws InterruptedException{
    68         Thread.sleep(2000);
    69 //        Map<String,Object> map=new HashMap<String,Object>();
    70 //        map.put("code", 200);
    71 //        map.put("info","工号【"+port+"】正在为您服务");
    72 //        return map;
    73         return this.studentService.hystrix();
    74     }
    75 
    76 //    public Map<String,Object> hystrixFallback() throws InterruptedException{
    77 //        Map<String,Object> map=new HashMap<String,Object>();
    78 //        map.put("code", 500);
    79 //        map.put("info", "系统【"+port+"】繁忙,稍后重试");
    80 //        return map;
    81 //    }
    82 
    83 }

    StudentService

     1 package com.yuan.microservicestudentproviderhystrix1004.service;
     2 
     3 import com.yuan.microservicecommon.entity.Student;
     4 
     5 import java.util.List;
     6 import java.util.Map;
     7 
     8 public interface StudentService {
     9  
    10     public void save(Student student);
    11      
    12     public Student findById(Integer id);
    13      
    14     public List<Student> list();
    15      
    16     public void delete(Integer id);
    17 
    18     /**
    19      * 测试Hystrix服务降级
    20      * @return
    21      */
    22     public Map<String,Object> hystrix();
    23      
    24      
    25 }

    实现类

     1 package com.yuan.microservicestudentproviderhystrix1004.service.impl;
     2 
     3 import com.yuan.microservicecommon.entity.Student;
     4 import com.yuan.microservicestudentproviderhystrix1004.repository.StudentRepository;
     5 import com.yuan.microservicestudentproviderhystrix1004.service.StudentService;
     6 import org.springframework.beans.factory.annotation.Autowired;
     7 import org.springframework.beans.factory.annotation.Value;
     8 import org.springframework.stereotype.Service;
     9 
    10 import java.util.HashMap;
    11 import java.util.List;
    12 import java.util.Map;
    13 
    14 @Service
    15 public class StudentServiceImpl implements StudentService {
    16     @Autowired
    17     private StudentRepository studentRepository;
    18 
    19     @Value("${server.port}")
    20     private String port;
    21 
    22     @Override
    23     public void save(Student student) {
    24         studentRepository.save(student);
    25     }
    26 
    27     @Override
    28     public Student findById(Integer id) {
    29         return studentRepository.findOne(id);
    30     }
    31 
    32     @Override
    33     public List<Student> list() {
    34         return studentRepository.findAll();
    35     }
    36 
    37     @Override
    38     public void delete(Integer id) {
    39         studentRepository.delete(id);
    40     }
    41 
    42     @Override
    43     public Map<String, Object> hystrix() {
    44         Map<String,Object> map=new HashMap<String,Object>();
    45         map.put("code", 200);
    46         map.put("info","工号【"+port+"】正在为您服务");
    47         return map;
    48     }
    49 }

    这类我们实现了 降级处理方法实现;

     

    3、microservice-student-consumer-feign-80修改 支持Hystrix

    StudentConsumerFeignController新增方法调用

    1 /**
    2  * Feign整合Hystrix服务熔断降级
    3  * @return
    4  * @throws InterruptedException
    5  */
    6 @GetMapping(value="/hystrix")
    7 public Map<String,Object> hystrix() throws InterruptedException{
    8     return studentClientService.hystrix();
    9 }

    microservice-student-consumer-feign-80application.yml加上hystrix支持

     1 server:
     2   port: 81
     3   context-path: /
     4 eureka:
     5   client:
     6     service-url:
     7       defaultZone: http://eureka2001.yuan.com:2001/eureka/,http://eureka2002.yuan.com:2002/eureka/,http://eureka2003.yuan.com:2003/eureka/
     8     register-with-eureka: false
     9 feign:
    10   hystrix:
    11     enabled: true
    12 ribbon:
    13   ReadTimeout: 10000
    14   ConnectTimeout: 9000

    1、microservice-student-consumer-feign-80的启动类上添加公共模块

    @ComponentScan(basePackages = {"com.javaxl.microservicecommon","com.javaxl.microservicestudentconsumerfeign80"})

    注意:

    公共子项目与当前子项目的基包都要扫描到;

    只指定公共子模块为基包会导致本子项目的springmvc功能失效;

    只指定本子项目为基包会导致feign与Hystrix集成失败,从而导致服务熔断功能失效

     1 package com.yuan.microservicestudentconsumerfeign80;
     2 
     3 import org.springframework.boot.SpringApplication;
     4 import org.springframework.boot.autoconfigure.SpringBootApplication;
     5 import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
     6 import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
     7 import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
     8 import org.springframework.cloud.netflix.feign.EnableFeignClients;
     9 import org.springframework.context.annotation.ComponentScan;
    10 
    11 @ComponentScan(basePackages = {"com.yuan.microservicecommon","com.yuan.microservicestudentconsumerfeign80"})//扫描公共模块
    12 @EnableFeignClients(value = "com.yuan.*.*")
    13 @EnableEurekaClient
    14 @SpringBootApplication(exclude={DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class})
    15 public class MicroserviceStudentConsumerFeign80Application {
    16 
    17     public static void main(String[] args) {
    18         SpringApplication.run(MicroserviceStudentConsumerFeign80Application.class, args);
    19     }
    20 
    21 }

    运行结果

     

    谢谢观看!!!

  • 相关阅读:
    C#设计模式——抽象工厂模式(原文转自:http://blog.jobbole.com/78059/)
    WebConfig配置文件详解(转载自逆心的博客)
    ASP.NET C# 日期 时间 年 月 日 时 分 秒 格式及转换(转自happymagic的专栏)
    ASP.NET RepeatLayout 属性
    牛顿迭代法
    汉诺塔(整理)
    游戏引擎---好牛(转)
    字符串相关面试题(整理)
    有关java调用批处理文件
    有关java 8
  • 原文地址:https://www.cnblogs.com/ly-0919/p/12031161.html
Copyright © 2011-2022 走看看