解决由于ControllerMethodsCache类的getMethod方法中,由于replace target写死造成的修改contextPath后找不到api的异常
This commit is contained in:
parent
4baaef4b5a
commit
071be5c3d4
@ -18,6 +18,7 @@ package com.alibaba.nacos.core.code;
|
|||||||
|
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.reflections.Reflections;
|
import org.reflections.Reflections;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@ -35,6 +36,9 @@ import java.util.concurrent.ConcurrentMap;
|
|||||||
@Component
|
@Component
|
||||||
public class ControllerMethodsCache {
|
public class ControllerMethodsCache {
|
||||||
|
|
||||||
|
@Value("${server.servlet.contextPath:/nacos}")
|
||||||
|
private String contextPath;
|
||||||
|
|
||||||
private ConcurrentMap<String, Method> methods = new
|
private ConcurrentMap<String, Method> methods = new
|
||||||
ConcurrentHashMap<>();
|
ConcurrentHashMap<>();
|
||||||
|
|
||||||
@ -43,7 +47,7 @@ public class ControllerMethodsCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Method getMethod(String httpMethod, String path) {
|
public Method getMethod(String httpMethod, String path) {
|
||||||
String key = httpMethod + "-->" + path.replace("/nacos", "");
|
String key = httpMethod + "-->" + path.replace(contextPath, "");
|
||||||
return methods.get(key);
|
return methods.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user