diff --git a/pom.xml b/pom.xml
index 31167e7..c563132 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
cn.langpy
ko-time
- 2.4.8
+ 2.4.9
KoTime
A springboot tool for tracking the paths of the methods,which can help you find method's performances easily.
diff --git a/src/main/java/cn/langpy/kotime/config/SaveResourceConfig.java b/src/main/java/cn/langpy/kotime/config/SaveResourceConfig.java
index 5cc8c67..55b4bb3 100644
--- a/src/main/java/cn/langpy/kotime/config/SaveResourceConfig.java
+++ b/src/main/java/cn/langpy/kotime/config/SaveResourceConfig.java
@@ -7,6 +7,7 @@ import cn.langpy.kotime.util.KoUtil;
import cn.langpy.kotime.util.MethodType;
import org.springframework.aop.MethodMatcher;
import org.springframework.aop.aspectj.AspectJExpressionPointcutAdvisor;
+import org.springframework.beans.BeansException;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.ApplicationContext;
import org.springframework.data.redis.core.StringRedisTemplate;
@@ -52,29 +53,42 @@ public class SaveResourceConfig implements CommandLineRunner {
acquireControllers();
}
private void acquireControllers() {
- RequestMappingHandlerMapping handlerMapping = applicationContext.getBean(RequestMappingHandlerMapping.class);
- Map handlerMethods = handlerMapping.getHandlerMethods();
- GraphService graphService = GraphService.getInstance();
- MethodMatcher methodMatcher = aspectJExpressionPointcutAdvisor.getPointcut().getMethodMatcher();
- for (Map.Entry methodEntry : handlerMethods.entrySet()) {
- HandlerMethod handlerMethod = methodEntry.getValue();
- boolean matches = methodMatcher.matches(handlerMethod.getMethod(), handlerMethod.getClass());
- if (matches) {
- MethodNode methodNode = toMethodNode(handlerMethod);
- graphService.addMethodNode(methodNode);
+ try {
+ RequestMappingHandlerMapping handlerMapping = applicationContext.getBean(RequestMappingHandlerMapping.class);
+ Map handlerMethods = handlerMapping.getHandlerMethods();
+ GraphService graphService = GraphService.getInstance();
+ MethodMatcher methodMatcher = aspectJExpressionPointcutAdvisor.getPointcut().getMethodMatcher();
+ for (Map.Entry methodEntry : handlerMethods.entrySet()) {
+ HandlerMethod handlerMethod = methodEntry.getValue();
+ boolean matches = methodMatcher.matches(handlerMethod.getMethod(), handlerMethod.getClass());
+ if (matches) {
+ MethodNode methodNode = toMethodNode(handlerMethod);
+ if (methodNode == null) {
+ continue;
+ }
+ graphService.addMethodNode(methodNode);
+ }
}
+ } catch (BeansException e) {
+ log.warning("kotime=>An error occured while loading all controllers:"+e.getMessage());
}
}
private MethodNode toMethodNode(HandlerMethod method) {
Class> beanType = method.getBeanType();
RequestMapping requestMapping = beanType.getAnnotation(RequestMapping.class);
+ if (requestMapping == null) {
+ return null;
+ }
String[] cvalues = requestMapping.value();
String classRoute = "";
if (cvalues != null && cvalues.length > 0) {
classRoute = cvalues[0];
}
RequestMapping methodAnnotation = method.getMethodAnnotation(RequestMapping.class);
+ if (requestMapping == null) {
+ return null;
+ }
String[] mvalues = methodAnnotation.value();
String methodRoute = "";
if (mvalues != null && mvalues.length > 0) {
diff --git a/src/main/resources/koapp.properties b/src/main/resources/koapp.properties
index 10c98e6..9696d4f 100644
--- a/src/main/resources/koapp.properties
+++ b/src/main/resources/koapp.properties
@@ -1 +1 @@
-ko-time.version=2.4.8
\ No newline at end of file
+ko-time.version=2.4.9
\ No newline at end of file