Sentinel
Sentinel copied to clipboard
网关限流添加api分组后无法找到服务
Issue Description
Type: bug report
Describe what happened (or what feature you want)
当我没有在网关添加api分组的时候,一切正常, 当我在网关中添加了api分组,启动网关之后,控制台无法看到网关服务。 When I did not add an API group to the gateway, everything was normal, When I add an api group to the gateway and start the gateway, the dashboard cannot see the gateway service.
这是我在GatewayConfig中添加的api分组 This is the api group I added in GatewayConfig
@PostConstruct
public void doInit() {
initCustomizedApis();
}
private void initCustomizedApis() {
Set<ApiDefinition> definitions = new HashSet<>();
ApiDefinition api1 = new ApiDefinition("custom_system")
.setPredicateItems(new HashSet<ApiPredicateItem>() {{
add(new ApiPathPredicateItem().setPattern("/system/sysUser/list"));
add(new ApiPathPredicateItem().setPattern("/system/sysOnline/**")
.setMatchStrategy(SentinelGatewayConstants.URL_MATCH_STRATEGY_PREFIX));
}});
definitions.add(api1);
GatewayApiDefinitionManager.loadApiDefinitions(definitions);
}
Describe what you expected to happen
How to reproduce it (as minimally and precisely as possible)
- sentinel version 1.8.5
- spring cloud alibaba version 2021.0.4.0
- fastjson version 2.0.10
- jdk version 1.8
- 其他配置和文档一致(Other configurations are consistent with the documents)
Tell us your environment
Windows11
Anything else we need to know?
确认网关有触发正常访问,相关排查可参考 FAQ.
遇到同样的问题,请问最后是怎么解决的
同样的问题,调用 GatewayApiDefinitionManager.loadApiDefinitions(definitions);后就失效。
且在http://ip:port/actuator/sentinel中,查不到信息。
不调用时,actuator中显示如下:
调用后显示显示如下: