Created
April 21, 2021 06:28
-
-
Save xinyii/fb63594a7b3516d8a1cf6e4f51fc10e0 to your computer and use it in GitHub Desktop.
[Spring Controller Scan] #spring
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
public class EndpointsListener implements ApplicationListener<ContextRefreshedEvent> { | |
@Override | |
public void onApplicationEvent(ContextRefreshedEvent event) { | |
ApplicationContext applicationContext = event.getApplicationContext(); | |
applicationContext.getBean(RequestMappingHandlerMapping.class).getHandlerMethods() | |
.forEach((requestMappingInfo, handlerMethod) -> { | |
Set<RequestMethod> methods = requestMappingInfo.getMethodsCondition().getMethods(); | |
Set<String> patterns = requestMappingInfo.getPatternsCondition().getPatterns(); | |
log.info("Method: {} Path: {}", methods, patterns); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment