admin 管理员组

文章数量: 887021


2024年2月25日发(作者:springboot nacos)

spring-cloud-starter-alibaba-nacos-config ${n} spring-cloud-starter-alibaba-nacos-discovery ${n} spring-cloud-starter-netflix-ribbon spring-cloud-starter-openfeign spring-boot-starter-web spring-boot-starter-test test e junit-vintage-engine spring-cloud-dependencies ${n} pom import spring-cloud-openfeign-dependencies ${n} pom import spring-boot-maven-plugin

ing: application: name: account-service cloud: nacos: config: server-addr: 127.0.0.1:ing: profiles: active: dev cloud: nacos: discovery: server-addr: 127.0.0.1:8848server: port: 8081feign: client: config: default: #default默认所有服务的超时时间 connect-timeout: 10000 read-timeout: 20000# payment-service: #指定payment-service这个服务的超时时间# connect-timeout: 10000# read-timeout: 20000controller

package ller;import eFeignService;import e;import ;import red;import ier;import tMapping;import tParam;import ntroller;import p;import ;@RestControllerpublic class AccountController { //@Qualifier("paymentService") @Autowired private BalanceFeignService balanceFeignService; final static Map userMap = new HashMap() {{ put(1, new User(1, "张三")); put(2, new User(2, "李四")); put(3, new User(3, "王五")); } }; @RequestMapping("/acc/user") public User getUser(@RequestParam Integer id) { if(id != null && nsKey(id)) { User user = (id); Balance balance = ance(id); if(balance != null){ ance(balance); } return user; } return new User(0, ""); }}启动类package tservice;import Application;import BootApplication;import DiscoveryClient;import FeignClients;@SpringBootApplication@EnableDiscoveryClient@EnableFeignClientspublic class AccountServiceApplication { public static void main(String[] args) { (, args); }}

feign: sentinel: enabled: true添加sentinel依赖 spring-cloud-starter-alibaba-sentinel ${n}


本文标签: 服务 添加 依赖 时间 默认