Browse Source

修改starter-api,增加获取ApiConfig的保护性逻辑

Signed-off-by: luoshi <luoshi@qmth.com.cn>
luoshi 11 months ago
parent
commit
4bb5357e23

+ 3 - 1
starter-api/src/main/java/com/qmth/boot/api/interceptor/AbstractInterceptor.java

@@ -22,7 +22,9 @@ public abstract class AbstractInterceptor extends HandlerInterceptorAdapter impl
         if (apiConfig == null) {
         if (apiConfig == null) {
             if (handler instanceof HandlerMethod) {
             if (handler instanceof HandlerMethod) {
                 apiConfig = apiConfigService.getApiConfig((HandlerMethod) handler);
                 apiConfig = apiConfigService.getApiConfig((HandlerMethod) handler);
-            } else {
+            }
+            // 容器尚未初始化完成时,按照配置构建以防报错
+            if (apiConfig == null) {
                 apiConfig = new ApiConfig(apiProperties);
                 apiConfig = new ApiConfig(apiProperties);
             }
             }
             request.setAttribute(ATTRIBUTE_API_CONFIG, apiConfig);
             request.setAttribute(ATTRIBUTE_API_CONFIG, apiConfig);