路由
routes:
- id: serviceA_route
uri: lb://serviceA
predicates:
- Path=/A/**
filters:
- StripPrefix=1
uri: lb://serviceA
中的serviceA找的是模块中名配置文件中的名字
其内的控制器就是根据你后面的路径找到对应的控制器中的方法
大体的理解就是如果你的请求路径是/A/**
那么就会到配置文件中名字为serviceA的模块中找对应的控制器
**就是对应模块中的控制器
控制器
@RestController
@RequestMapping("serviceA")
public class ServiceAController {
@GetMapping("/helloA")
public String helloA() {
return "nacos";
}
}
访问的网址
http://localhost:9000/A/serviceA/helloA
如果是没有控制前的@RequestMapping(“serviceA”),那么访问的路径为
http://localhost:9000/A/helloA