spring cloud 消费者 提供者

nacos为注册中心
spring:
  main:
    allow-bean-definition-overriding: true
  profiles:
    active: dev
  application:
    name: nacos-credit
  cloud:
    nacos:
      discovery:
        server-addr: 39.107.73.16:8848
        namespace: bee94379-2f03-4cd7-947b-46548359e2fa
      config:
        server-addr: 39.107.73.16:8848
        file-extension: yml
        group: DEFAULT_GROUP
        refresh: true
        timeout: 5000


<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-openfeign</artifactId>
    <version>2.1.2.RELEASE</version>
</dependency>

// 消费者
@EnableFeignClients
public class CreditApplication {
}

@FeignClient(name="nacos-report/hqreport",fallback = ConsumMarvelsLgasApiImpl.class)
public interface ConsumMarvelsLgasApi {
    @RequestMapping(value = "/apiService/count", method = RequestMethod.POST, consumes = "application/json")
    String freezeAmount(String param);
}

@Component
public class ConsumMarvelsLgasApiImpl implements ConsumMarvelsLgasApi{
    @Override
    public String freezeAmount(String param) {
        // TODO Auto-generated method stub
        return null;
    }
}

// 提供者
@EnableDiscoveryClient
public class CreditApplication {
}




 

posted @ 2020-09-10 11:18  悟空为师想要吃肉  阅读(159)  评论(0)    收藏  举报