错误信息:
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: org.springframework.util.StringUtils.matchesCharacter(Ljava/lang/String;C)Z] with root cause
java.lang.NoSuchMethodError: org.springframework.util.StringUtils.matchesCharacter(Ljava/lang/String;C)Z
at org.springframework.web.util.UrlPathHelper.getContextPath(UrlPathHelper.java:398) ~[spring-web-5.2.9.RELEASE.jar:5.2.9.RELEASE]
at org.springframework.web.util.UrlPathHelper.getPathWithinApplication(UrlPathHelper.java:297) ~[spring-web-5.2.9.RELEASE.jar:5.2.9.RELEASE]
at org.springframework.web.util.UrlPathHelper.getLookupPathForRequest(UrlPathHelper.java:186) ~[spring-web-5.2.9.RELEASE.jar:5.2.9.RELEASE]
at org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.getHandlerInternal(AbstractUrlHandlerMapping.java:123) ~[spring-webmvc-5.1.10.RELEASE.jar:5.1.10.RELEASE]
通常是这三种解决方式
1.controller层没有加@ResponseBody
2.Service层实现类未添加注解@Autowired
3.@RestController使用成了@Controller
但是我这次不一样
也不能盲目参考解决方式,要对症下药,比如我这次的错误!!!!!!!!!!!!!!!!!!!
上图红色框出来的部分:java.lang.NoSuchMethodError: org.springframework.util.StringUtils.matchesCharacter(Ljava/lang/String;C)Z
at org.springframework.web.util.UrlPathHelper.getContextPath(UrlPathHelper.java:398) ~[spring-web-5.2.9.RELEASE.jar:5.2.9.RELEASE]
at org.springframework.web.util.UrlPathHelper.getPathWithinApplication(UrlPathHelper.java:297) ~[spring-web-5.2.9.RELEASE.jar:5.2.9.RELEASE]
at org.springframework.web.util.UrlPathHelper.getLookupPathForRequest(UrlPathHelper.java:186) ~[spring-web-5.2.9.RELEASE.jar:5.2.9.RELEASE]
然后我就看了我项目引的jar包!!!!!!!!!!!
原来是我引得包与sringboot包冲突了,把它注释掉即可正常运行,访问接口!!!!!!!!!完美解决!!!!!!!