admin管理员组文章数量:1568303
今天在使用swagger时遇到了如下报错:
WARN 19704 --- [ main]
ConfigServletWebServerApplicationContext :
Exception encountered during context initialization - cancelling refresh attempt:
org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper';
nested exception is java.lang.NullPointerException
查了资料发现是swagger版本与springboot版本不兼容的问题,在spring配置文件 application.properties 中添加如下代码成功解决:
spring.mvc.pathmatch.matching-strategy=ant_path_matcher
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.7.4)
2022-10-10 19:24:46.945 INFO 16516 --- [ main] com.atguigu.eduservice.EduApplication : Starting EduApplication using Java 1.8.0_322 on LAPTOP-7FA7QIA3 with PID 16516 (D:\IDEA_files\guli_parent\service\service_edu\target\classes started by 16937 in D:\IDEA_files\guli_parent)
2022-10-10 19:24:46.947 INFO 16516 --- [ main] com.atguigu.eduservice.EduApplication : The following 1 profile is active: "dev"
2022-10-10 19:24:47.498 INFO 16516 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode
2022-10-10 19:24:47.500 INFO 16516 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Redis repositories in DEFAULT mode.
2022-10-10 19:24:47.514 INFO 16516 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 6 ms. Found 0 Redis repository interfaces.
2022-10-10 19:24:47.844 INFO 16516 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8001 (http)
2022-10-10 19:24:47.850 INFO 16516 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-10-10 19:24:47.850 INFO 16516 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.65]
2022-10-10 19:24:48.000 INFO 16516 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2022-10-10 19:24:48.000 INFO 16516 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1026 ms
Logging initialized using 'class org.apache.ibatis.logging.stdout.StdOutImpl' adapter.
_ _ |_ _ _|_. ___ _ | _
| | |\/|_)(_| | |_\ |_)||_|_\
/ |
3.0.5
2022-10-10 19:24:48.141 INFO 16516 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2022-10-10 19:24:48.370 INFO 16516 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
Property 'mapperLocations' was not specified or no matching resources found
2022-10-10 19:24:48.678 INFO 16516 --- [ main] pertySourcedRequestMappingHandlerMapping : Mapped URL path [/v2/api-docs] onto method [springfox.documentation.swagger2.web.Swagger2Controller#getDocumentation(String, HttpServletRequest)]
2022-10-10 19:24:49.085 INFO 16516 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8001 (http) with context path ''
2022-10-10 19:24:49.086 INFO 16516 --- [ main] d.s.w.p.DocumentationPluginsBootstrapper : Context refreshed
2022-10-10 19:24:49.097 INFO 16516 --- [ main] d.s.w.p.DocumentationPluginsBootstrapper : Found 1 custom documentation plugin(s)
2022-10-10 19:24:49.119 INFO 16516 --- [ main] s.d.s.w.s.ApiListingReferenceScanner : Scanning for api listing references
2022-10-10 19:24:49.216 INFO 16516 --- [ main] com.atguigu.eduservice.EduApplication : Started EduApplication in 2.539 seconds (JVM running for 3.588)
本文标签: 报错解决方法encounteredExceptionswagger
版权声明:本文标题:使用swagger报错:Exception encountered during context initialization - cancelling refresh attempt解决方法 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dianzi/1726224505a1061345.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论