古人学问无遗力,少壮工夫老始成。这篇文章主要讲述Springboot 2.X的RequestMapping 的映射路径怎么看不到了?相关的知识,希望能为你提供帮助。
在使用spring boot 1.X的时候我们可以在console中看到mapping的映射路径
1 2020-01-12 19:10:19.996INFO 2711 --- [main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity< java.util.Map< java.lang.String, java.lang.Object> > org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest) 2 2020-01-12 19:10:19.997INFO 2711 --- [main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) 3 2020-01-12 19:10:20.026INFO 2711 --- [main] o.s.w.s.handler.SimpleUrlHandlerMapping: Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 4 2020-01-12 19:10:20.026INFO 2711 --- [main] o.s.w.s.handler.SimpleUrlHandlerMapping: Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 5 2020-01-12 19:10:20.065INFO 2711 --- [main] o.s.w.s.handler.SimpleUrlHandlerMapping: Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 6 2020-01-12 19:10:20.422INFO 2711 --- [main] uration$$EnhancerBySpringCGLIB$$8e8eae03 : No deployment resources were found for autodeployment 7 2020-01-12 19:10:20.574INFO 2711 --- [main] uration$$EnhancerBySpringCGLIB$$e60feff5 : No deployment resources were found for autodeployment 8 2020-01-12 19:10:20.614INFO 2711 --- [main] uration$$EnhancerBySpringCGLIB$$2a356a63 : No deployment resources were found for autodeployment
开发的时候有这个可以方便的解决404的问题,可以看看自己新添加的接口有没有映射上去。
为什么我升级为2.2.1就不行了呢。。
一番查找之后发现
【Springboot 2.X的RequestMapping 的映射路径怎么看不到了()】Spring Boot 2.1 以后 使用了 Spring Framework 5.1, 而 Spring Framework 5.1 对日志做了较大的改动。现在使用 INFO 级别记录的信息非常少,DEBUG 级别提供了更多信息,但不详细。只有 TRACE 级别才会提供详细信息。这时候为了要打印Controller里面的 RequestMapping信息需要把org.springframework.web打印日志的格式设置为trace,示例如下:
logging: level: # root: info # org.mybatis: debug # java.sql: debug org.springframework.web: trace
加上日志级别后终于出来了
2020-01-12 19:19:01.286 TRACE 3010 --- [main] s.w.s.m.m.a.RequestMappingHandlerMapping : o.s.b.a.w.s.e.BasicErrorController: { /error}: error(HttpServletRequest) { /error, produces [text/html]}: errorHtml(HttpServletRequest,HttpServletResponse) 2020-01-12 19:19:01.291 DEBUG 3010 --- [main] s.w.s.m.m.a.RequestMappingHandlerMapping : 2 mappings in ‘requestMappingHandlerMapping‘
说的
推荐阅读
- uni-app三目运算uni-app监听属性
- uni-app 计算属性 computed
- SpringMVC框架-使用注解编写的处理请求和映射-@Controller@RequestMapping
- Android 7.0 以上 Charles 和 Fiddler 无法抓取 HTTPS 包的解决方式
- 关于uniapp版本的问题
- UIautomator2 安卓自动化教程
- Android/Unity大乱斗-完整双方集成交互指南
- Android开发之sd卡存储和机身存储的路径获取
- 升级code11.3后遇到React Native启动报错的问题 getCurrentAppState:error 和 objectAtIndexedSubscript: 的解决方案